1 57 58 package com.sun.org.apache.xerces.internal.parsers; 59 60 import com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl; 61 import com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl; 62 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator; 63 import com.sun.org.apache.xerces.internal.impl.dtd.XMLNSDTDValidator; 64 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator; 65 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter; 66 import com.sun.org.apache.xerces.internal.util.SymbolTable; 67 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; 68 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent; 69 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager; 70 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentScanner; 71 72 110 public class IntegratedParserConfiguration 111 extends StandardParserConfiguration { 112 113 114 119 120 protected XMLNSDocumentScannerImpl fNamespaceScanner; 121 122 123 protected XMLDocumentScannerImpl fNonNSScanner; 124 125 126 protected XMLDTDValidator fNonNSDTDValidator; 127 128 132 133 public IntegratedParserConfiguration() { 134 this(null, null, null); 135 } 137 142 public IntegratedParserConfiguration(SymbolTable symbolTable) { 143 this(symbolTable, null, null); 144 } 146 157 public IntegratedParserConfiguration(SymbolTable symbolTable, 158 XMLGrammarPool grammarPool) { 159 this(symbolTable, grammarPool, null); 160 } 162 174 public IntegratedParserConfiguration(SymbolTable symbolTable, 175 XMLGrammarPool grammarPool, 176 XMLComponentManager parentSettings) { 177 super(symbolTable, grammarPool, parentSettings); 178 179 fNonNSScanner = new XMLDocumentScannerImpl(); 181 fNonNSDTDValidator = new XMLDTDValidator(); 182 183 addComponent((XMLComponent)fNonNSScanner); 185 addComponent((XMLComponent)fNonNSDTDValidator); 186 187 } 189 190 191 protected void configurePipeline() { 192 193 setProperty(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory); 195 196 configureDTDPipeline(); 198 199 if (fFeatures.get(NAMESPACES) == Boolean.TRUE) { 201 fProperties.put(NAMESPACE_BINDER, fNamespaceBinder); 202 fScanner = fNamespaceScanner; 203 fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner); 204 if (fDTDValidator != null) { 205 fProperties.put(DTD_VALIDATOR, fDTDValidator); 206 fNamespaceScanner.setDTDValidator(fDTDValidator); 207 fNamespaceScanner.setDocumentHandler(fDTDValidator); 208 fDTDValidator.setDocumentSource(fNamespaceScanner); 209 fDTDValidator.setDocumentHandler(fDocumentHandler); 210 if (fDocumentHandler != null) { 211 fDocumentHandler.setDocumentSource(fDTDValidator); 212 } 213 fLastComponent = fDTDValidator; 214 } 215 else { 216 fNamespaceScanner.setDocumentHandler(fDocumentHandler); 217 fNamespaceScanner.setDTDValidator(null); 218 if (fDocumentHandler != null) { 219 fDocumentHandler.setDocumentSource(fNamespaceScanner); 220 } 221 fLastComponent = fNamespaceScanner; 222 } 223 } 224 else { 225 fScanner = fNonNSScanner; 226 fProperties.put(DOCUMENT_SCANNER, fNonNSScanner); 227 if (fNonNSDTDValidator != null) { 228 fProperties.put(DTD_VALIDATOR, fNonNSDTDValidator); 229 fNonNSScanner.setDocumentHandler(fNonNSDTDValidator); 230 fNonNSDTDValidator.setDocumentSource(fNonNSScanner); 231 fNonNSDTDValidator.setDocumentHandler(fDocumentHandler); 232 if (fDocumentHandler != null) { 233 fDocumentHandler.setDocumentSource(fNonNSDTDValidator); 234 } 235 fLastComponent = fNonNSDTDValidator; 236 } 237 else { 238 fScanner.setDocumentHandler(fDocumentHandler); 239 if (fDocumentHandler != null) { 240 fDocumentHandler.setDocumentSource(fScanner); 241 } 242 fLastComponent = fScanner; 243 } 244 } 245 246 if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) { 248 if (fSchemaValidator == null) { 250 fSchemaValidator = new XMLSchemaValidator(); 251 252 fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator); 254 addComponent(fSchemaValidator); 255 if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) { 257 XSMessageFormatter xmft = new XSMessageFormatter(); 258 fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft); 259 } 260 261 } 262 263 fLastComponent.setDocumentHandler(fSchemaValidator); 264 fSchemaValidator.setDocumentSource(fLastComponent); 265 fSchemaValidator.setDocumentHandler(fDocumentHandler); 266 if (fDocumentHandler != null) { 267 fDocumentHandler.setDocumentSource(fSchemaValidator); 268 } 269 fLastComponent = fSchemaValidator; 270 } 271 } 273 274 275 277 protected XMLDocumentScanner createDocumentScanner() { 278 fNamespaceScanner = new XMLNSDocumentScannerImpl(); 279 return fNamespaceScanner; 280 } 282 283 285 protected XMLDTDValidator createDTDValidator() { 286 return new XMLNSDTDValidator(); 287 } 289 } 291 | Popular Tags |