1 16 17 package org.apache.xerces.parsers; 18 19 import org.apache.xerces.impl.XMLDocumentScannerImpl; 20 import org.apache.xerces.impl.XMLNSDocumentScannerImpl; 21 import org.apache.xerces.impl.dtd.XMLDTDValidator; 22 import org.apache.xerces.impl.dtd.XMLNSDTDValidator; 23 import org.apache.xerces.impl.xs.XMLSchemaValidator; 24 import org.apache.xerces.impl.xs.XSMessageFormatter; 25 import org.apache.xerces.util.SymbolTable; 26 import org.apache.xerces.xni.grammars.XMLGrammarPool; 27 import org.apache.xerces.xni.parser.XMLComponent; 28 import org.apache.xerces.xni.parser.XMLComponentManager; 29 import org.apache.xerces.xni.parser.XMLDocumentScanner; 30 31 69 public class IntegratedParserConfiguration 70 extends StandardParserConfiguration { 71 72 73 78 79 protected XMLNSDocumentScannerImpl fNamespaceScanner; 80 81 82 protected XMLDocumentScannerImpl fNonNSScanner; 83 84 85 protected XMLDTDValidator fNonNSDTDValidator; 86 87 91 92 public IntegratedParserConfiguration() { 93 this(null, null, null); 94 } 96 101 public IntegratedParserConfiguration(SymbolTable symbolTable) { 102 this(symbolTable, null, null); 103 } 105 116 public IntegratedParserConfiguration(SymbolTable symbolTable, 117 XMLGrammarPool grammarPool) { 118 this(symbolTable, grammarPool, null); 119 } 121 133 public IntegratedParserConfiguration(SymbolTable symbolTable, 134 XMLGrammarPool grammarPool, 135 XMLComponentManager parentSettings) { 136 super(symbolTable, grammarPool, parentSettings); 137 138 fNonNSScanner = new XMLDocumentScannerImpl(); 140 fNonNSDTDValidator = new XMLDTDValidator(); 141 142 addComponent((XMLComponent)fNonNSScanner); 144 addComponent((XMLComponent)fNonNSDTDValidator); 145 146 } 148 149 150 protected void configurePipeline() { 151 152 setProperty(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory); 154 155 configureDTDPipeline(); 157 158 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 } 174 else { 175 fNamespaceScanner.setDocumentHandler(fDocumentHandler); 176 fNamespaceScanner.setDTDValidator(null); 177 if (fDocumentHandler != null) { 178 fDocumentHandler.setDocumentSource(fNamespaceScanner); 179 } 180 fLastComponent = fNamespaceScanner; 181 } 182 } 183 else { 184 fScanner = fNonNSScanner; 185 fProperties.put(DOCUMENT_SCANNER, fNonNSScanner); 186 if (fNonNSDTDValidator != null) { 187 fProperties.put(DTD_VALIDATOR, fNonNSDTDValidator); 188 fNonNSScanner.setDocumentHandler(fNonNSDTDValidator); 189 fNonNSDTDValidator.setDocumentSource(fNonNSScanner); 190 fNonNSDTDValidator.setDocumentHandler(fDocumentHandler); 191 if (fDocumentHandler != null) { 192 fDocumentHandler.setDocumentSource(fNonNSDTDValidator); 193 } 194 fLastComponent = fNonNSDTDValidator; 195 } 196 else { 197 fScanner.setDocumentHandler(fDocumentHandler); 198 if (fDocumentHandler != null) { 199 fDocumentHandler.setDocumentSource(fScanner); 200 } 201 fLastComponent = fScanner; 202 } 203 } 204 205 if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) { 207 if (fSchemaValidator == null) { 209 fSchemaValidator = new XMLSchemaValidator(); 210 211 fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator); 213 addComponent(fSchemaValidator); 214 if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) { 216 XSMessageFormatter xmft = new XSMessageFormatter(); 217 fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft); 218 } 219 220 } 221 222 fLastComponent.setDocumentHandler(fSchemaValidator); 223 fSchemaValidator.setDocumentSource(fLastComponent); 224 fSchemaValidator.setDocumentHandler(fDocumentHandler); 225 if (fDocumentHandler != null) { 226 fDocumentHandler.setDocumentSource(fSchemaValidator); 227 } 228 fLastComponent = fSchemaValidator; 229 } 230 } 232 233 234 236 protected XMLDocumentScanner createDocumentScanner() { 237 fNamespaceScanner = new XMLNSDocumentScannerImpl(); 238 return fNamespaceScanner; 239 } 241 242 244 protected XMLDTDValidator createDTDValidator() { 245 return new XMLNSDTDValidator(); 246 } 248 } 250 | Popular Tags |