Source Code Cross Referenced for XPathFactoryImpl.java in  » XML » XPath-Saxon » net » sf » saxon » xpath » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » XPath Saxon » net.sf.saxon.xpath 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.xpath;
002:
003:        import net.sf.saxon.Configuration;
004:        import net.sf.saxon.FeatureKeys;
005:        import net.sf.saxon.om.NamespaceConstant;
006:        import net.sf.saxon.om.Validation;
007:
008:        import javax.xml.XMLConstants;
009:        import javax.xml.xpath.*;
010:
011:        /**
012:         * Saxon implementation of the JAXP 1.3 XPathFactory
013:         */
014:        public class XPathFactoryImpl extends XPathFactory {
015:
016:            private Configuration config;
017:            private XPathVariableResolver variableResolver;
018:            private XPathFunctionResolver functionResolver;
019:
020:            public XPathFactoryImpl() {
021:                config = makeConfiguration();
022:            }
023:
024:            protected Configuration makeConfiguration() {
025:                return new Configuration();
026:            }
027:
028:            /**
029:             * Get the Configuration object
030:             */
031:
032:            public Configuration getConfiguration() {
033:                return config;
034:            }
035:
036:            /**
037:             * Test whether a given object model is supported. Returns true if the object model
038:             * is the Saxon object model, DOM, JDOM, or XOM
039:             * @param model The URI identifying the object model.
040:             * @return true if the object model is one of
041:             * {@link NamespaceConstant#OBJECT_MODEL_SAXON},
042:             * {@link XPathConstants#DOM_OBJECT_MODEL},
043:             * {@link NamespaceConstant#OBJECT_MODEL_JDOM}, or
044:             * {@link NamespaceConstant#OBJECT_MODEL_XOM}
045:             */
046:            public boolean isObjectModelSupported(String model) {
047:                if (model.equals(NamespaceConstant.OBJECT_MODEL_SAXON))
048:                    return true;
049:                if (model.equals(XPathConstants.DOM_OBJECT_MODEL))
050:                    return true;
051:                if (model.equals(NamespaceConstant.OBJECT_MODEL_JDOM))
052:                    return true;
053:                if (model.equals(NamespaceConstant.OBJECT_MODEL_XOM))
054:                    return true;
055:                return false;
056:            }
057:
058:            /**
059:             * Set a feature of this XPath implementation. The only features currently
060:             * recognized are:
061:             * <ul>
062:             * <li> {@link XMLConstants#FEATURE_SECURE_PROCESSING} </li>
063:             * <li> {@link net.sf.saxon.FeatureKeys#SCHEMA_VALIDATION}: requests schema validation of source documents.
064:             *   The property is rejected if the configuration is not schema-aware. </li>
065:             * </ul>
066:             * @param feature a URI identifying the feature
067:             * @param b true to set the feature on, false to set it off
068:             * @throws XPathFactoryConfigurationException if the feature name is not recognized
069:             */
070:
071:            public void setFeature(String feature, boolean b)
072:                    throws XPathFactoryConfigurationException {
073:                if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
074:                    config.setAllowExternalFunctions(!b);
075:                } else if (feature.equals(FeatureKeys.SCHEMA_VALIDATION)) {
076:                    config.setSchemaValidationMode(b ? Validation.STRICT
077:                            : Validation.STRIP);
078:                } else {
079:                    throw new XPathFactoryConfigurationException(
080:                            "Unknown feature: " + feature);
081:                }
082:            }
083:
084:            /**
085:             * Get a feature of this XPath implementation. The only features currently
086:             * recognized are:
087:             * <ul>
088:             * <li> {@link XMLConstants#FEATURE_SECURE_PROCESSING} </li>
089:             * <li> {@link net.sf.saxon.FeatureKeys#SCHEMA_VALIDATION}: requests schema validation of source documents. </li>
090:             * </ul>
091:             * @param feature a URI identifying the feature
092:             * @return true if the feature is on, false if it is off
093:             * @throws XPathFactoryConfigurationException if the feature name is not recognized
094:             */
095:
096:            public boolean getFeature(String feature)
097:                    throws XPathFactoryConfigurationException {
098:                if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
099:                    return !config.isAllowExternalFunctions();
100:                } else if (feature.equals(FeatureKeys.SCHEMA_VALIDATION)) {
101:                    return config.getSchemaValidationMode() == Validation.STRICT;
102:                } else {
103:                    throw new XPathFactoryConfigurationException(
104:                            "Unknown feature: " + feature);
105:                }
106:            }
107:
108:            /**
109:             * Set a resolver for XPath variables. This will be used to obtain the value of
110:             * any variable referenced in an XPath expression. The variable resolver must be allocated
111:             * before the expression is compiled, but it will only be called when the expression
112:             * is evaluated.
113:             * @param xPathVariableResolver The object used to resolve references to variables.
114:             */
115:            public void setXPathVariableResolver(
116:                    XPathVariableResolver xPathVariableResolver) {
117:                variableResolver = xPathVariableResolver;
118:            }
119:
120:            /**
121:             * Set a resolver for XPath functions. This will be used to obtain an implementation
122:             * of any external function referenced in an XPath expression. This is not required for
123:             * system functions, Saxon extension functions, constructor functions named after types,
124:             * or extension functions bound using a namespace that maps to a Java class.
125:             * @param xPathFunctionResolver The object used to resolve references to external functions.
126:             */
127:
128:            public void setXPathFunctionResolver(
129:                    XPathFunctionResolver xPathFunctionResolver) {
130:                functionResolver = xPathFunctionResolver;
131:            }
132:
133:            /**
134:             * Create an XPath evaluator
135:             * @return an XPath object, which can be used to compile and execute XPath expressions.
136:             */
137:            public XPath newXPath() {
138:                XPathEvaluator xpath = new XPathEvaluator(config);
139:                xpath.setXPathFunctionResolver(functionResolver);
140:                xpath.setXPathVariableResolver(variableResolver);
141:                //config.registerStandardObjectModels();
142:                return xpath;
143:            }
144:
145:        }
146:
147:        //
148:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
149:        // you may not use this file except in compliance with the License. You may obtain a copy of the
150:        // License at http://www.mozilla.org/MPL/
151:        //
152:        // Software distributed under the License is distributed on an "AS IS" basis,
153:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
154:        // See the License for the specific language governing rights and limitations under the License.
155:        //
156:        // The Original Code is: all this file.
157:        //
158:        // The Initial Developer of the Original Code is Michael H. Kay.
159:        //
160:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
161:        //
162:        // Contributor(s):
163:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.