Source Code Cross Referenced for IntegratedParserConfiguration.java in  » XML » xerces-2_9_1 » org » apache » xerces » parsers » 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 » xerces 2_9_1 » org.apache.xerces.parsers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.xerces.parsers;
019:
020:        import org.apache.xerces.impl.XMLDocumentScannerImpl;
021:        import org.apache.xerces.impl.XMLNSDocumentScannerImpl;
022:        import org.apache.xerces.impl.dtd.XMLDTDValidator;
023:        import org.apache.xerces.impl.dtd.XMLNSDTDValidator;
024:        import org.apache.xerces.impl.xs.XMLSchemaValidator;
025:        import org.apache.xerces.impl.xs.XSMessageFormatter;
026:        import org.apache.xerces.util.SymbolTable;
027:        import org.apache.xerces.xni.grammars.XMLGrammarPool;
028:        import org.apache.xerces.xni.parser.XMLComponent;
029:        import org.apache.xerces.xni.parser.XMLComponentManager;
030:        import org.apache.xerces.xni.parser.XMLDocumentScanner;
031:
032:        /**
033:         * This is configuration uses a scanner that integrates both scanning of the document
034:         * and binding namespaces.
035:         *
036:         * If namespace feature is turned on, the pipeline is constructured with the 
037:         * following components:
038:         * XMLNSDocumentScannerImpl -> XMLNSDTDValidator -> (optional) XMLSchemaValidator
039:         * 
040:         * If the namespace feature is turned off the default document scanner implementation
041:         * is used (XMLDocumentScannerImpl).
042:         * <p>
043:         * In addition to the features and properties recognized by the base
044:         * parser configuration, this class recognizes these additional 
045:         * features and properties:
046:         * <ul>
047:         * <li>Features
048:         *  <ul>
049:         *  <li>http://apache.org/xml/features/validation/schema</li>
050:         *  <li>http://apache.org/xml/features/validation/schema-full-checking</li>
051:         *  <li>http://apache.org/xml/features/validation/schema/normalized-value</li>
052:         *  <li>http://apache.org/xml/features/validation/schema/element-default</li>
053:         *  </ul>
054:         * <li>Properties
055:         *  <ul>
056:         *   <li>http://apache.org/xml/properties/internal/error-reporter</li>
057:         *   <li>http://apache.org/xml/properties/internal/entity-manager</li>
058:         *   <li>http://apache.org/xml/properties/internal/document-scanner</li>
059:         *   <li>http://apache.org/xml/properties/internal/dtd-scanner</li>
060:         *   <li>http://apache.org/xml/properties/internal/grammar-pool</li>
061:         *   <li>http://apache.org/xml/properties/internal/validator/dtd</li>
062:         *   <li>http://apache.org/xml/properties/internal/datatype-validator-factory</li>
063:         *  </ul>
064:         * </ul>
065:         *
066:         * @author Elena Litani, IBM
067:         *
068:         * @version $Id: IntegratedParserConfiguration.java 447239 2006-09-18 05:08:26Z mrglavas $
069:         */
070:        public class IntegratedParserConfiguration extends
071:                StandardParserConfiguration {
072:
073:            //
074:            // REVISIT: should this configuration depend on the others
075:            //          like DTD/Standard one?
076:            //
077:
078:            /** Document scanner that does namespace binding. */
079:            protected XMLNSDocumentScannerImpl fNamespaceScanner;
080:
081:            /** Default Xerces implementation of scanner */
082:            protected XMLDocumentScannerImpl fNonNSScanner;
083:
084:            /** DTD Validator that does not bind namespaces */
085:            protected XMLDTDValidator fNonNSDTDValidator;
086:
087:            //
088:            // Constructors
089:            //
090:
091:            /** Default constructor. */
092:            public IntegratedParserConfiguration() {
093:                this (null, null, null);
094:            } // <init>()
095:
096:            /** 
097:             * Constructs a parser configuration using the specified symbol table. 
098:             *
099:             * @param symbolTable The symbol table to use.
100:             */
101:            public IntegratedParserConfiguration(SymbolTable symbolTable) {
102:                this (symbolTable, null, null);
103:            } // <init>(SymbolTable)
104:
105:            /**
106:             * Constructs a parser configuration using the specified symbol table and
107:             * grammar pool.
108:             * <p>
109:             * <strong>REVISIT:</strong> 
110:             * Grammar pool will be updated when the new validation engine is
111:             * implemented.
112:             *
113:             * @param symbolTable The symbol table to use.
114:             * @param grammarPool The grammar pool to use.
115:             */
116:            public IntegratedParserConfiguration(SymbolTable symbolTable,
117:                    XMLGrammarPool grammarPool) {
118:                this (symbolTable, grammarPool, null);
119:            } // <init>(SymbolTable,XMLGrammarPool)
120:
121:            /**
122:             * Constructs a parser configuration using the specified symbol table,
123:             * grammar pool, and parent settings.
124:             * <p>
125:             * <strong>REVISIT:</strong> 
126:             * Grammar pool will be updated when the new validation engine is
127:             * implemented.
128:             *
129:             * @param symbolTable    The symbol table to use.
130:             * @param grammarPool    The grammar pool to use.
131:             * @param parentSettings The parent settings.
132:             */
133:            public IntegratedParserConfiguration(SymbolTable symbolTable,
134:                    XMLGrammarPool grammarPool,
135:                    XMLComponentManager parentSettings) {
136:                super (symbolTable, grammarPool, parentSettings);
137:
138:                // create components
139:                fNonNSScanner = new XMLDocumentScannerImpl();
140:                fNonNSDTDValidator = new XMLDTDValidator();
141:
142:                // add components
143:                addComponent((XMLComponent) fNonNSScanner);
144:                addComponent((XMLComponent) fNonNSDTDValidator);
145:
146:            } // <init>(SymbolTable,XMLGrammarPool)
147:
148:            /** Configures the pipeline. */
149:            protected void configurePipeline() {
150:
151:                // use XML 1.0 datatype library
152:                setProperty(DATATYPE_VALIDATOR_FACTORY,
153:                        fDatatypeValidatorFactory);
154:
155:                // setup DTD pipeline
156:                configureDTDPipeline();
157:
158:                // setup document pipeline
159:                if (fFeatures.get(NAMESPACES) == Boolean.TRUE) {
160:                    fProperties.put(NAMESPACE_BINDER, fNamespaceBinder);
161:                    fScanner = fNamespaceScanner;
162:                    fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner);
163:                    if (fDTDValidator != null) {
164:                        fProperties.put(DTD_VALIDATOR, fDTDValidator);
165:                        fNamespaceScanner.setDTDValidator(fDTDValidator);
166:                        fNamespaceScanner.setDocumentHandler(fDTDValidator);
167:                        fDTDValidator.setDocumentSource(fNamespaceScanner);
168:                        fDTDValidator.setDocumentHandler(fDocumentHandler);
169:                        if (fDocumentHandler != null) {
170:                            fDocumentHandler.setDocumentSource(fDTDValidator);
171:                        }
172:                        fLastComponent = fDTDValidator;
173:                    } else {
174:                        fNamespaceScanner.setDocumentHandler(fDocumentHandler);
175:                        fNamespaceScanner.setDTDValidator(null);
176:                        if (fDocumentHandler != null) {
177:                            fDocumentHandler
178:                                    .setDocumentSource(fNamespaceScanner);
179:                        }
180:                        fLastComponent = fNamespaceScanner;
181:                    }
182:                } else {
183:                    fScanner = fNonNSScanner;
184:                    fProperties.put(DOCUMENT_SCANNER, fNonNSScanner);
185:                    if (fNonNSDTDValidator != null) {
186:                        fProperties.put(DTD_VALIDATOR, fNonNSDTDValidator);
187:                        fNonNSScanner.setDocumentHandler(fNonNSDTDValidator);
188:                        fNonNSDTDValidator.setDocumentSource(fNonNSScanner);
189:                        fNonNSDTDValidator.setDocumentHandler(fDocumentHandler);
190:                        if (fDocumentHandler != null) {
191:                            fDocumentHandler
192:                                    .setDocumentSource(fNonNSDTDValidator);
193:                        }
194:                        fLastComponent = fNonNSDTDValidator;
195:                    } else {
196:                        fScanner.setDocumentHandler(fDocumentHandler);
197:                        if (fDocumentHandler != null) {
198:                            fDocumentHandler.setDocumentSource(fScanner);
199:                        }
200:                        fLastComponent = fScanner;
201:                    }
202:                }
203:
204:                // setup document pipeline
205:                if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) {
206:                    // If schema validator was not in the pipeline insert it.
207:                    if (fSchemaValidator == null) {
208:                        fSchemaValidator = new XMLSchemaValidator();
209:
210:                        // add schema component
211:                        fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator);
212:                        addComponent(fSchemaValidator);
213:                        // add schema message formatter
214:                        if (fErrorReporter
215:                                .getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
216:                            XSMessageFormatter xmft = new XSMessageFormatter();
217:                            fErrorReporter.putMessageFormatter(
218:                                    XSMessageFormatter.SCHEMA_DOMAIN, xmft);
219:                        }
220:
221:                    }
222:
223:                    fLastComponent.setDocumentHandler(fSchemaValidator);
224:                    fSchemaValidator.setDocumentSource(fLastComponent);
225:                    fSchemaValidator.setDocumentHandler(fDocumentHandler);
226:                    if (fDocumentHandler != null) {
227:                        fDocumentHandler.setDocumentSource(fSchemaValidator);
228:                    }
229:                    fLastComponent = fSchemaValidator;
230:                }
231:            } // configurePipeline()
232:
233:            /** Create a document scanner: this scanner performs namespace binding 
234:             */
235:            protected XMLDocumentScanner createDocumentScanner() {
236:                fNamespaceScanner = new XMLNSDocumentScannerImpl();
237:                return fNamespaceScanner;
238:            } // createDocumentScanner():XMLDocumentScanner
239:
240:            /** Create a DTD validator: this validator performs namespace binding.
241:             */
242:            protected XMLDTDValidator createDTDValidator() {
243:                return new XMLNSDTDValidator();
244:            } // createDTDValidator():XMLDTDValidator
245:
246:        } // class IntegratedParserConfiguration
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.