private XMLParserConfiguration initialize() { XML11Configuration config = new XML11Configuration(); config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER)); config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER)); XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER); config.setProperty(ERROR_REPORTER, errorReporter); // add message formatters if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { XMLMessageFormatter xmft = new XMLMessageFormatter(); errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft); errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft); } config.setProperty(SYMBOL_TABLE, fComponentManager.getProperty(SYMBOL_TABLE)); config.setProperty(VALIDATION_MANAGER, fComponentManager.getProperty(VALIDATION_MANAGER)); config.setProperty(SECURITY_MANAGER, fComponentManager.getProperty(SECURITY_MANAGER)); config.setDocumentHandler(fSchemaValidator); config.setDTDHandler(null); config.setDTDContentModelHandler(null); fConfiguration = new SoftReference(config); return config; }
/** * Adds common component to the parser configuration. This method will * also add all of the component's recognized features and properties * to the list of default recognized features and properties. * * @param component The component to add. */ protected void addCommonComponent(XMLComponent component) { // don't add a component more than once if (fCommonComponents.contains(component)) { return; } fCommonComponents.add(component); addRecognizedParamsAndSetDefaults(component); } // addCommonComponent(XMLComponent)
private void initXML11Components() { if (!f11Initialized) { // create datatype factory fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY); // setup XML 1.1 DTD pipeline fXML11DTDScanner = new XML11DTDScannerImpl(); addXML11Component(fXML11DTDScanner); fXML11DTDProcessor = new XML11DTDProcessor(); addXML11Component(fXML11DTDProcessor); // setup XML 1.1. document pipeline - namespace aware fXML11NSDocScanner = new XML11NSDocumentScannerImpl(); addXML11Component(fXML11NSDocScanner); fXML11NSDTDValidator = new XML11NSDTDValidator(); addXML11Component(fXML11NSDTDValidator); f11Initialized = true; } }
private void createAnnotationValidator() { fAnnotationValidator = new XML11Configuration(); fGrammarBucketAdapter = new XSAnnotationGrammarPool(fSchemaVersion); fAnnotationValidator.setFeature(VALIDATION, true); fAnnotationValidator.setFeature(XMLSCHEMA_VALIDATION, true); fAnnotationValidator.setProperty(XMLGRAMMAR_POOL, fGrammarBucketAdapter); /** Set error handler. **/ XMLErrorHandler errorHandler = fErrorReporter.getErrorHandler(); fAnnotationValidator.setProperty(ERROR_HANDLER, (errorHandler != null) ? errorHandler : new DefaultErrorHandler()); /** Set locale. **/ Locale locale = fErrorReporter.getLocale(); fAnnotationValidator.setProperty(LOCALE, locale); }
synchronized SAXParser getSAXParser() { if (fSAXParser != null) { SAXParser parser = (SAXParser) fSAXParser.get(); if (parser != null) { return parser; } } // REVISIT: when schema handles XML 1.1, will need to // revisit this (and the practice of not prepending an XML decl to the annotation string XML11Configuration config = new XML11Configuration(fSymbolTable); // note that this should never produce errors or require // entity resolution, so just a barebones configuration with // a couple of feature set will do fine config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false); SAXParser parser = new SAXParser(config); fSAXParser = new SoftReference(parser); return parser; }
setInputSource(source); parse(true); } catch (XNIException ex) { if (PRINT_EXCEPTION_STACK_TRACE) fParseInProgress = false; this.cleanup();
fValidationManager.reset(); fVersionDetector.reset(this); resetCommon(); configurePipeline(); reset(); initXML11Components(); configureXML11Pipeline(); resetXML11();
addRecognizedFeatures(recognizedFeatures); SCHEMA_DV_FACTORY, }; addRecognizedProperties(recognizedProperties); addCommonComponent(fEntityManager); addCommonComponent(fErrorReporter); addComponent((XMLComponent) fNamespaceScanner); addComponent((XMLComponent) fDTDScanner); addComponent(fDTDProcessor); addComponent(fDTDValidator); setLocale(Locale.getDefault()); } catch (XNIException e) {
if (fCurrentDVFactory != fXML11DatatypeFactory) { fCurrentDVFactory = fXML11DatatypeFactory; setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory); setProperty(DTD_SCANNER, fCurrentDTDScanner); setProperty(DTD_PROCESSOR, fXML11DTDProcessor); if (fCurrentScanner != fXML11NSDocScanner) { fCurrentScanner = fXML11NSDocScanner; setProperty(DOCUMENT_SCANNER, fXML11NSDocScanner); setProperty(DTD_VALIDATOR, fXML11NSDTDValidator); addXML11Component(fXML11DocScanner); fXML11DTDValidator = new XML11DTDValidator(); addXML11Component(fXML11DTDValidator); setProperty(DOCUMENT_SCANNER, fXML11DocScanner); setProperty(DTD_VALIDATOR, fXML11DTDValidator); fSchemaValidator = new XMLSchemaValidator(); setProperty(SCHEMA_VALIDATOR, fSchemaValidator); addCommonComponent(fSchemaValidator); fSchemaValidator.reset(this);
fCurrentDVFactory = fDatatypeValidatorFactory; setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory); setProperty(DTD_SCANNER, fCurrentDTDScanner); setProperty(DTD_PROCESSOR, fDTDProcessor); if (fCurrentScanner != fNamespaceScanner) { fCurrentScanner = fNamespaceScanner; setProperty(DOCUMENT_SCANNER, fNamespaceScanner); setProperty(DTD_VALIDATOR, fDTDValidator); fNonNSDTDValidator = new XMLDTDValidator(); addComponent((XMLComponent) fNonNSScanner); addComponent((XMLComponent) fNonNSDTDValidator); setProperty(DOCUMENT_SCANNER, fNonNSScanner); setProperty(DTD_VALIDATOR, fNonNSDTDValidator); fSchemaValidator = new XMLSchemaValidator(); setProperty(SCHEMA_VALIDATOR, fSchemaValidator); addCommonComponent(fSchemaValidator); fSchemaValidator.reset(this);
protected void configureXML11Pipeline() { super.configureXML11Pipeline();
addRecognizedFeatures(recognizedFeatures); addRecognizedProperties(recognizedProperties);
public XMLReader createXMLReader() throws SAXException { final XMLParserConfiguration configuration = new XML11Configuration(); final SAXParser parser = new TeedaSAXParser(configuration); final XMLFilter filter = new TeedaXMLFilter(parser); filter.setProperty(PROPERTY_LEXICAL_HANDLER, filter); filter.setFeature(FEATURE_NAMESPACE_PREFIXES, true); filter.setFeature(FEATURE_NOTIFY_CHAR_REFS, true); filter.setFeature(FEATURE_NOTIFY_BUILTIN_REFS, true); return filter; } }
synchronized DOMParser getDOMParser() { if (fDOMParser != null) { DOMParser parser = (DOMParser) fDOMParser.get(); if (parser != null) { return parser; } } // REVISIT: when schema handles XML 1.1, will need to // revisit this (and the practice of not prepending an XML decl to the annotation string XML11Configuration config = new XML11Configuration(fSymbolTable); // note that this should never produce errors or require // entity resolution, so just a barebones configuration with // a couple of feature set will do fine config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); config.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, false); DOMParser parser = new DOMParser(config); try { parser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.DEFER_NODE_EXPANSION_FEATURE, false); } catch (SAXException exc) {} fDOMParser = new SoftReference(parser); return parser; }
protected void configureXML11Pipeline() { super.configureXML11Pipeline();
protected void configureXML11Pipeline() { super.configureXML11Pipeline(); if (fXIncludeEnabled) {
/** * Adds an XML 1.1 component to the parser configuration. This method will * also add all of the component's recognized features and properties * to the list of default recognized features and properties. * * @param component The component to add. */ protected void addXML11Component(XMLComponent component) { // don't add a component more than once if (fXML11Components.contains(component)) { return; } fXML11Components.add(component); addRecognizedParamsAndSetDefaults(component); } // addXML11Component(XMLComponent)
super.configurePipeline(); if (fXIncludeEnabled) {