Class ParserCreator


  • @API(type=NOT_EXTENDABLE,
         src=PUBLIC)
    public class ParserCreator
    extends java.lang.Object
    Creates all the parsers from the system. All have catalog resolvers, except the ones with specified FakeResolver.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ASSERT_COMMENT_PI_CHECKING_ID
      Feature identifier: Enables comments and PIs for assertions processing
      static java.lang.String BASE_URI_FIXUP
      Feature identifier: base uri fixup.
      static java.lang.String CTA_FULL_XPATH_FEATURE_ID
      Feature identifier: Full XPath 2.0 for CTA evaluations
      static int VALIDATE
      Check that the document is conformant to a strict set of rules.
      static int VALIDATE_OR_WELLFORMED
      If the document declares the use of a schema, then it will be used validation, otherwise only a wellformed check will be done.
      static int WELLFORMED
      Check if the document is conformant to a relaxed set of rules.
      static java.lang.String XINCLUDE_FEATURE
      Feature identifier: XInclude processing
      static java.lang.String XML_SCHEMA_VERSION
      The XML schema version Xerces parser property
    • Constructor Summary

      Constructors 
      Constructor Description
      ParserCreator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.xml.sax.XMLReader changeValidationMode​(org.xml.sax.XMLReader parser, int validationMode)
      Changes the validation mode.
      static javax.xml.transform.sax.SAXSource createCatalogSAXSource​(javax.xml.transform.stream.StreamSource streamSource)
      Create a SAX source starting from a stream source/
      static javax.xml.transform.Source createCatalogSource​(javax.xml.transform.Source source)
      Adds an XML reader with a catalog resolver in case of a stream source transforming it into a SAXSource.
      static org.apache.xerces.parsers.DOMParser createDOMParser()
      Create a DOM parser.
      static org.apache.xerces.parsers.XMLGrammarPreparser createDTDValidationPreparser()
      Creates a preparser for DTD validation.
      static org.apache.xerces.parsers.DOMParser createGrammarCachedDOMParser​(ro.sync.xml.parser.GrammarCache xgp)
      Create a DOM parser with cached grammar
      static org.xml.sax.XMLReader createGrammarCachedXMLReader​(ro.sync.xml.parser.GrammarCache xgp, boolean valid)
      Create an XML reader with cached grammar
      static org.xml.sax.XMLReader createGrammarCachedXMLReader​(ro.sync.xml.parser.GrammarCache xgp, boolean valid, ro.sync.exml.editor.xsdeditor.XMLSchemaVersion version)
      Create an XML reader with cached grammar
      static org.apache.xerces.parsers.XMLGrammarPreparser createMultipleSchemasPreparser​(org.xml.sax.InputSource[] sources)
      Gets the XSD's Grammars from XSD Files URLs
      static org.apache.xerces.parsers.XMLGrammarPreparser createSchemaValidationPreparser​(ro.sync.exml.editor.xsdeditor.XMLSchemaVersion schemaVersion)
      Creates a preparser for schema validation.
      static org.apache.xerces.util.SynchronizedXMLGrammarPoolImpl createXMLGrammarPool​(ro.sync.xml.parser.GrammarCache xgp)
      Create the XML Grammar Pool
      static ro.sync.exml.editor.xsdeditor.XMLSchemaVersion getSchemaVersionFromParser​(org.xml.sax.XMLReader parser)
      Gets the schema version set the parser and converts the Xerces schema version, that can be Constants.W3C_XML_SCHEMA11_NS_URI, or Constants.W3C_XML_SCHEMA10_NS_URI, to an XMLSchemaVersion object.
      static java.lang.String getXercesSchemaVersionPropertyValue​(ro.sync.exml.editor.xsdeditor.XMLSchemaVersion schemaVersion)
      Converts the given enum constant representing an XML Schema version to a String value to be set for the Xerces property XML_SCHEMA_VERSION.
      static org.apache.xerces.xni.parser.XMLInputSource getXMLInputSource​(org.xml.sax.InputSource source)
      Carefully creates an XMLInputSource from an InputSource.
      static org.apache.xerces.parsers.DOMParser newAttrOrderDomParser​(boolean sortAttributes, boolean preserveNotNormalizedAttributeValues)
      Creates a DOM parser that preserves the order of attributes as they are received from Xerces.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilder()
      Creates a document buider with a catalog reslover.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver, boolean noExpand, boolean namespaceAware)
      Create a document builder.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver, boolean noExpand, boolean namespaceAware, java.net.URL schemaUrl)
      Create a document builder.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver, boolean noExpand, boolean namespaceAware, java.net.URL schemaUrl, boolean schemaAware)
      Create a document builder.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver, boolean noExpand, boolean namespaceAware, java.net.URL schemaUrl, boolean schemaAware, boolean forceXIncludeAndBaseURIFixup)
      Create a document builder.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver, boolean noExpand, boolean namespaceAware, java.net.URL schemaUrl, boolean schemaAware, boolean forceXIncludeAndBaseURIFixup, boolean dynamicValidation)
      Create a document builder.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilderFakeResolver()
      Creates a document buider with a fake resolver.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilderNoExpand()
      Creates a document buider with a catalog reslover.
      static javax.xml.parsers.DocumentBuilder newDocumentBuilderNS()
      Creates a document builder which is namespace aware.
      static org.xml.sax.XMLReader newDTDXRFullValidIdCollector​(java.util.List<ro.sync.xml.parser.IDValue> idValues, org.apache.xerces.util.SynchronizedXMLGrammarPoolImpl xgp)
      Creates an XMLReader that collects ID Attributes values with full validation and schema checking, disabled std.output and with no resolver set.
      static org.xml.sax.XMLReader newDTDXRFullValidIdCollector​(java.util.List<ro.sync.xml.parser.IDValue> idValues, ro.sync.xml.parser.GrammarCache xgc)
      Creates an XMLReader that collects ID Attributes values with full validation and schema checking, disabled std.output and with no resolver set.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParser()
      Creates a DOM Parser that populates with location information the nodes.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParser​(org.apache.xerces.xni.parser.XMLParserConfiguration config, boolean dtdAware)
      Creates a DOM Parser that populates with location information the nodes.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserForXpath()
      Creates a Location DOM Parser that is tuned for XPath.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserForXpath​(ro.sync.basic.execution.ExecutionStopper executionStopper)
      Creates a Location DOM Parser that is tuned for XPath.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserForXpath​(ro.sync.basic.execution.ExecutionStopper executionStopper, org.apache.xerces.xni.grammars.XMLGrammarPool gp)
      Creates a Location DOM Parser that is tuned for XPath.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserNoResolver()
      Creates a DOM parser that has no catalog resolver.
      static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserNoResolverForDiff()
      Creates a DOM parser that has no catalog resolver, no DTD validation for last stage and no RNG defaults processing.
      static com.thaiopensource.validate.ValidationDriver newRelaxNGValidator​(org.xml.sax.ErrorHandler errorHandler, boolean useCompactSyntax)
      Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
      static com.thaiopensource.validate.ValidationDriver newRelaxNGValidator​(org.xml.sax.ErrorHandler errorHandler, boolean useCompactSyntax, java.util.List<ro.sync.xml.parser.IDValue> idList)
      Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
      static com.thaiopensource.validate.ValidationDriver newRelaxNGValidator​(org.xml.sax.ErrorHandler errorHandler, boolean useCompactSyntax, java.util.List idList, com.thaiopensource.xml.sax.XMLReaderCreator readerCreator)
      Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
      static com.thaiopensource.validate.ValidationDriver newRelaxNGValidatorNoOptions​(org.xml.sax.ErrorHandler errorHandler, boolean useCompactSyntax)
      Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
      static javax.xml.parsers.DocumentBuilder newSchemaAwareDocumentBuilder()
      Creates a document buider with a catalog resolver.
      static org.xml.sax.XMLReader newWSDLFullValid​(org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
      Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set for WSDL validation.
      static org.apache.xerces.xni.parser.XMLParserConfiguration newXmlParserConfiguration​(org.apache.xerces.util.SymbolTable st, org.apache.xerces.xni.grammars.XMLGrammarPool xgp, java.util.List<ro.sync.xml.parser.IDValue> idValues, boolean fakeResolver)
      Creates new XMLParserConfiguration depending on options and the list of idValues.
      static org.apache.xerces.xni.parser.XMLParserConfiguration newXmlParserConfiguration​(org.apache.xerces.util.SymbolTable st, org.apache.xerces.xni.grammars.XMLGrammarPool xgp, java.util.List<ro.sync.xml.parser.IDValue> idValues, boolean fakeResolver, boolean dtdValidateForLastStage)
      Creates new XMLParserConfiguration depending on options and the list of idValues.
      static org.apache.xerces.xni.parser.XMLParserConfiguration newXmlParserConfiguration​(org.apache.xerces.util.SymbolTable st, org.apache.xerces.xni.grammars.XMLGrammarPool xgp, java.util.List<ro.sync.xml.parser.IDValue> idValues, boolean fakeResolver, boolean dtdValidateForLastStage, boolean forceDisableRNGDefaults)
      Creates new XMLParserConfiguration depending on options and the list of idValues.
      static org.xml.sax.XMLReader newXRFullValid()
      Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set.
      static org.xml.sax.XMLReader newXRFullValid​(org.apache.xerces.util.SynchronizedXMLGrammarPoolImpl xgp)
      Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set.
      static org.xml.sax.XMLReader newXRFullValid​(org.apache.xerces.xni.parser.XMLParserConfiguration parserConfig)
      Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set.
      static org.xml.sax.XMLReader newXRFullValidCompoundResolver​(org.xml.sax.EntityResolver entityResolver)
      Creates a XMLReader with disabled std.output and a compond resolver, from the catalog resolver and the given resolver.
      static org.xml.sax.XMLReader newXRFullValidIdCollector​(java.util.List<ro.sync.xml.parser.IDValue> idValues)
      Creates an XMLReader that collects ID Attributes values with full validation and schema checking, disabled std.output and with no resolver set.
      static org.xml.sax.XMLReader newXRNoValid()
      Creates a XMLReader with disabled std.output and with no extra resolver.
      static org.xml.sax.XMLReader newXRNoValid​(org.apache.xerces.xni.grammars.XMLGrammarPool gp)
      Creates a XMLReader with disabled std.output and with no extra resolver.
      static org.xml.sax.XMLReader newXRNoValid​(ro.sync.xml.parser.GrammarCache grammarCache)
      New XML reader not valid with grammar caching support.
      static org.xml.sax.XMLReader newXRNoValidCompoundResolver​(org.xml.sax.EntityResolver entityResolver)
      Creates a XMLReader with disabled std.output and a compound resolver, from the catalog resolver and the given resolver.
      static org.xml.sax.XMLReader newXRNoValidFakeResolver()
      Creates a XMLReader with disabled std.output and with a fake resolver.
      static org.xml.sax.XMLReader newXRNoValidNoRNGDefaults()
      New XML reader not valid without expansion of default RNG attributes.
      static org.xml.sax.XMLReader newXRValid​(org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
      Creates a XMLReader with validation support.
      static void setAcceptUndeclaredEntities​(org.apache.xerces.parsers.DOMParser parser)
      Set accept undeclared entities for the DOM parser.
      static void setGrammarCacheToParser​(ro.sync.xml.parser.GrammarCache xgp, org.apache.xerces.parsers.DOMParser parser)
      Set the grammar cache to the parser.
      static void setParserSystemProperties()
      Sets the parser JAXP properties to point to the correct implementation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • XINCLUDE_FEATURE

        public static final java.lang.String XINCLUDE_FEATURE
        Feature identifier: XInclude processing
        See Also:
        Constant Field Values
      • BASE_URI_FIXUP

        public static final java.lang.String BASE_URI_FIXUP
        Feature identifier: base uri fixup.
        See Also:
        Constant Field Values
      • VALIDATE

        public static final int VALIDATE
        Check that the document is conformant to a strict set of rules. See validation for XML with a Schema DTD, or XSL when checking if it produces a valid Transformer.
        See Also:
        Constant Field Values
      • WELLFORMED

        public static final int WELLFORMED
        Check if the document is conformant to a relaxed set of rules. See the well formed on XML.
        See Also:
        Constant Field Values
      • VALIDATE_OR_WELLFORMED

        public static final int VALIDATE_OR_WELLFORMED
        If the document declares the use of a schema, then it will be used validation, otherwise only a wellformed check will be done.
        See Also:
        Constant Field Values
      • XML_SCHEMA_VERSION

        public static final java.lang.String XML_SCHEMA_VERSION
        The XML schema version Xerces parser property
        See Also:
        Constant Field Values
      • CTA_FULL_XPATH_FEATURE_ID

        public static final java.lang.String CTA_FULL_XPATH_FEATURE_ID
        Feature identifier: Full XPath 2.0 for CTA evaluations
        See Also:
        Constant Field Values
      • ASSERT_COMMENT_PI_CHECKING_ID

        public static final java.lang.String ASSERT_COMMENT_PI_CHECKING_ID
        Feature identifier: Enables comments and PIs for assertions processing
        See Also:
        Constant Field Values
    • Constructor Detail

      • ParserCreator

        public ParserCreator()
    • Method Detail

      • newDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver,
                                                                           boolean noExpand,
                                                                           boolean namespaceAware)
                                                                    throws javax.xml.parsers.ParserConfigurationException
        Create a document builder.
        Parameters:
        fakeResolver - true if a fake resolver should be used as an entity resolver. If false it will use oxygen catalog an entity resolver from CatalogResolverFactory.
        noExpand - If true the entities will not be expanded.
        namespaceAware - true to activate namespace awareness.
        Returns:
        A document builder.
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • newDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver,
                                                                           boolean noExpand,
                                                                           boolean namespaceAware,
                                                                           java.net.URL schemaUrl)
                                                                    throws javax.xml.parsers.ParserConfigurationException
        Create a document builder.
        Parameters:
        fakeResolver - true if a fake resolver should be used as an entity resolver. If false it will use oxygen catalog an entity resolver from CatalogResolverFactory.
        noExpand - If true the entities will not be expanded.
        namespaceAware - true to activate namespace awareness.
        schemaUrl - The XML schema that should be used for validation.
        Returns:
        A document builder.
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • newDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver,
                                                                           boolean noExpand,
                                                                           boolean namespaceAware,
                                                                           java.net.URL schemaUrl,
                                                                           boolean schemaAware)
                                                                    throws javax.xml.parsers.ParserConfigurationException
        Create a document builder.
        Parameters:
        fakeResolver - true if a fake resolver should be used as an entity resolver. If false it will use oxygen catalog an entity resolver from CatalogResolverFactory.
        noExpand - If true the entities will not be expanded.
        namespaceAware - true to activate namespace awareness.
        schemaUrl - The XML schema that should be used for validation.
        schemaAware - True if schema aware
        Returns:
        A document builder.
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • newDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver,
                                                                           boolean noExpand,
                                                                           boolean namespaceAware,
                                                                           java.net.URL schemaUrl,
                                                                           boolean schemaAware,
                                                                           boolean forceXIncludeAndBaseURIFixup)
                                                                    throws javax.xml.parsers.ParserConfigurationException
        Create a document builder.
        Parameters:
        fakeResolver - true if a fake resolver should be used as an entity resolver. If false it will use oxygen catalog an entity resolver from CatalogResolverFactory.
        noExpand - If true the entities will not be expanded.
        namespaceAware - true to activate namespace awareness.
        schemaUrl - The XML schema that should be used for validation.
        schemaAware - True if schema aware
        forceXIncludeAndBaseURIFixup - true if the XInclude support must be enabled no matter the options. Base URI fixup will also be enabled.
        Returns:
        A document builder.
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • newDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilder​(boolean fakeResolver,
                                                                           boolean noExpand,
                                                                           boolean namespaceAware,
                                                                           java.net.URL schemaUrl,
                                                                           boolean schemaAware,
                                                                           boolean forceXIncludeAndBaseURIFixup,
                                                                           boolean dynamicValidation)
                                                                    throws javax.xml.parsers.ParserConfigurationException
        Create a document builder.
        Parameters:
        fakeResolver - true if a fake resolver should be used as an entity resolver. If false it will use oxygen catalog an entity resolver from CatalogResolverFactory.
        noExpand - If true the entities will not be expanded.
        namespaceAware - true to activate namespace awareness.
        schemaUrl - The XML schema that should be used for validation.
        schemaAware - True if schema aware
        forceXIncludeAndBaseURIFixup - true if the XInclude support must be enabled no matter the options. Base URI fixup will also be enabled.
        dynamicValidation - true if the dynamic valication feature should be active.
        Returns:
        A document builder.
        Throws:
        javax.xml.parsers.ParserConfigurationException
      • newSchemaAwareDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newSchemaAwareDocumentBuilder()
                                                                               throws javax.xml.parsers.ParserConfigurationException
        Creates a document buider with a catalog resolver. The builder is schema aware (for DITA use) and gets the default attributes specified from the XML Schema as well.
        Returns:
        The Document Builder
        Throws:
        javax.xml.parsers.ParserConfigurationException - When the parsers are not conf. properly.
      • newDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilder()
                                                                    throws javax.xml.parsers.ParserConfigurationException
        Creates a document buider with a catalog reslover.
        Returns:
        The Document Builder
        Throws:
        javax.xml.parsers.ParserConfigurationException - When the parsers are not conf. properly.
      • newDocumentBuilderFakeResolver

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilderFakeResolver()
                                                                                throws javax.xml.parsers.ParserConfigurationException
        Creates a document buider with a fake resolver.
        Returns:
        The Document Builder
        Throws:
        javax.xml.parsers.ParserConfigurationException - When the parsers are not conf. properly.
      • newDocumentBuilderNoExpand

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilderNoExpand()
                                                                            throws javax.xml.parsers.ParserConfigurationException
        Creates a document buider with a catalog reslover. Does not expand external entities.
        Returns:
        The Document Builder
        Throws:
        javax.xml.parsers.ParserConfigurationException - When the parsers are not conf. properly.
      • newDocumentBuilderNS

        public static javax.xml.parsers.DocumentBuilder newDocumentBuilderNS()
                                                                      throws javax.xml.parsers.ParserConfigurationException
        Creates a document builder which is namespace aware. Attaches a catalog resolver to it.
        Returns:
        a new DocumentBuilder
        Throws:
        javax.xml.parsers.ParserConfigurationException - When the parsers are not conf. properly.
      • newXmlParserConfiguration

        public static org.apache.xerces.xni.parser.XMLParserConfiguration newXmlParserConfiguration​(org.apache.xerces.util.SymbolTable st,
                                                                                                    org.apache.xerces.xni.grammars.XMLGrammarPool xgp,
                                                                                                    java.util.List<ro.sync.xml.parser.IDValue> idValues,
                                                                                                    boolean fakeResolver)
        Creates new XMLParserConfiguration depending on options and the list of idValues.
        Parameters:
        st - The symbol table used during parsing.
        xgp - The grammar pool.
        idValues - The list of the collected id values. If not null creates a PSVIConfiguration.
        fakeResolver - true if a fake resolver will be imposed on the parser at a later time. This means the default XInclude processing should be disabled in this case, otherwise the document parsing will break in the first xi:include reference.
        Returns:
        The new XMLParserConfiguration.
      • newXmlParserConfiguration

        public static org.apache.xerces.xni.parser.XMLParserConfiguration newXmlParserConfiguration​(org.apache.xerces.util.SymbolTable st,
                                                                                                    org.apache.xerces.xni.grammars.XMLGrammarPool xgp,
                                                                                                    java.util.List<ro.sync.xml.parser.IDValue> idValues,
                                                                                                    boolean fakeResolver,
                                                                                                    boolean dtdValidateForLastStage)
        Creates new XMLParserConfiguration depending on options and the list of idValues.
        Parameters:
        st - The symbol table used during parsing.
        xgp - The grammar pool.
        idValues - The list of the collected id values. If not null creates a PSVIConfiguration.
        fakeResolver - true if a fake resolver will be imposed on the parser at a later time. This means the default XInclude processing should be disabled in this case, otherwise the document parsing will break in the first xi:include reference.
        dtdValidateForLastStage - Add the DTD validation as the last stage in the parser.
        Returns:
        The new XMLParserConfiguration.
      • newXmlParserConfiguration

        public static org.apache.xerces.xni.parser.XMLParserConfiguration newXmlParserConfiguration​(org.apache.xerces.util.SymbolTable st,
                                                                                                    org.apache.xerces.xni.grammars.XMLGrammarPool xgp,
                                                                                                    java.util.List<ro.sync.xml.parser.IDValue> idValues,
                                                                                                    boolean fakeResolver,
                                                                                                    boolean dtdValidateForLastStage,
                                                                                                    boolean forceDisableRNGDefaults)
        Creates new XMLParserConfiguration depending on options and the list of idValues.
        Parameters:
        st - The symbol table used during parsing.
        xgp - The grammar pool.
        idValues - The list of the collected id values. If not null creates a PSVIConfiguration.
        fakeResolver - true if a fake resolver will be imposed on the parser at a later time. This means the default XInclude processing should be disabled in this case, otherwise the document parsing will break in the first xi:include reference.
        dtdValidateForLastStage - Add the DTD validation as the last stage in the parser.
        forceDisableRNGDefaults - true if the RNG defaults should be disabled no matter what the option says. This is used for diff parser.
        Returns:
        The new XMLParserConfiguration.
      • newXRNoValidFakeResolver

        public static org.xml.sax.XMLReader newXRNoValidFakeResolver()
        Creates a XMLReader with disabled std.output and with a fake resolver. The parser is NOT continuing after fatal error and is not validating.
        Returns:
        an XMLReader
      • newXRFullValidCompoundResolver

        public static org.xml.sax.XMLReader newXRFullValidCompoundResolver​(org.xml.sax.EntityResolver entityResolver)
        Creates a XMLReader with disabled std.output and a compond resolver, from the catalog resolver and the given resolver. The parser is continuing after fatal error and is validating.
        Parameters:
        entityResolver - The entity resolver to be compound with the xml catalog resolver.
        Returns:
        an XMLReader
      • newXRNoValidCompoundResolver

        public static org.xml.sax.XMLReader newXRNoValidCompoundResolver​(org.xml.sax.EntityResolver entityResolver)
        Creates a XMLReader with disabled std.output and a compound resolver, from the catalog resolver and the given resolver. The parser is NOT continuing after fatal error and is not validating.
        Parameters:
        entityResolver - The entity resolver to be compound with the xml catalog resolver.
        Returns:
        an XMLReader
      • newXRNoValid

        public static org.xml.sax.XMLReader newXRNoValid​(org.apache.xerces.xni.grammars.XMLGrammarPool gp)
        Creates a XMLReader with disabled std.output and with no extra resolver. The parser is NOT continuing after fatal error and is not validating. The catalog resolver is installed.
        Parameters:
        gp - Grammar pool which can be reused.
        Returns:
        an XMLReader
      • newXRNoValid

        public static org.xml.sax.XMLReader newXRNoValid()
        Creates a XMLReader with disabled std.output and with no extra resolver. The parser is NOT continuing after fatal error and is not validating. The catalog resolver is installed.
        Returns:
        an XMLReader
      • newXRFullValid

        public static org.xml.sax.XMLReader newXRFullValid​(org.apache.xerces.util.SynchronizedXMLGrammarPoolImpl xgp)
        Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Parameters:
        xgp - XML Grammar pool
        Returns:
        an XMLReader
      • newXRFullValid

        public static org.xml.sax.XMLReader newXRFullValid()
        Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Returns:
        an XMLReader
      • newXRFullValid

        public static org.xml.sax.XMLReader newXRFullValid​(org.apache.xerces.xni.parser.XMLParserConfiguration parserConfig)
        Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Parameters:
        parserConfig - The parser configuration
        Returns:
        an XMLReader
      • newWSDLFullValid

        public static org.xml.sax.XMLReader newWSDLFullValid​(org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
        Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set for WSDL validation. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Parameters:
        grammarPool - The pool containing the grammars the parser must use to validate the documents.
        Returns:
        an XMLReader
      • newXRValid

        public static org.xml.sax.XMLReader newXRValid​(org.apache.xerces.xni.grammars.XMLGrammarPool grammarPool)
        Creates a XMLReader with validation support. The parser has the catalog entity resolver.
        Parameters:
        grammarPool - In this pool the parser stores the grammars. They can be further used to examine them.
        Returns:
        an XMLReader
      • newRelaxNGValidator

        public static com.thaiopensource.validate.ValidationDriver newRelaxNGValidator​(org.xml.sax.ErrorHandler errorHandler,
                                                                                       boolean useCompactSyntax)
        Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
        Parameters:
        errorHandler - The error handler to be set to the parser.
        useCompactSyntax - If true the Relax NG grammar is in compact syntax otherwise in XML syntax.
        Returns:
        Verifier the new Relax NG verifier. A ValidationDriver instance.
      • newRelaxNGValidator

        public static com.thaiopensource.validate.ValidationDriver newRelaxNGValidator​(org.xml.sax.ErrorHandler errorHandler,
                                                                                       boolean useCompactSyntax,
                                                                                       java.util.List<ro.sync.xml.parser.IDValue> idList)
        Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
        Parameters:
        errorHandler - The error handler to be set to the parser.
        useCompactSyntax - If true the Relax NG grammar is in compact syntax otherwise in XML syntax.
        idList - The list of id values to be colected.
        Returns:
        Verifier the new Relax NG verifier. A ValidationDriver instance.
      • newRelaxNGValidatorNoOptions

        public static com.thaiopensource.validate.ValidationDriver newRelaxNGValidatorNoOptions​(org.xml.sax.ErrorHandler errorHandler,
                                                                                                boolean useCompactSyntax)
        Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
        Parameters:
        errorHandler - The error handler to be set to the parser.
        useCompactSyntax - If true the Relax NG grammar is in compact syntax otherwise in XML syntax.
        Returns:
        Verifier the new Relax NG verifier. A ValidationDriver instance.
      • newRelaxNGValidator

        public static com.thaiopensource.validate.ValidationDriver newRelaxNGValidator​(org.xml.sax.ErrorHandler errorHandler,
                                                                                       boolean useCompactSyntax,
                                                                                       java.util.List idList,
                                                                                       com.thaiopensource.xml.sax.XMLReaderCreator readerCreator)
        Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.
        Parameters:
        errorHandler - The error handler to be set to the parser.
        useCompactSyntax - If true the Relax NG grammar is in compact syntax otherwise in XML syntax.
        idList - The list of id values to be colected.
        readerCreator - The XMLReaderCreator to be used.
        Returns:
        Verifier the new Relax NG verifier. A ValidationDriver instance.
      • newAttrOrderDomParser

        public static org.apache.xerces.parsers.DOMParser newAttrOrderDomParser​(boolean sortAttributes,
                                                                                boolean preserveNotNormalizedAttributeValues)
                                                                         throws org.xml.sax.SAXException
        Creates a DOM parser that preserves the order of attributes as they are received from Xerces.
        Parameters:
        sortAttributes - True if the attributes must be sorted. This is the default implementation in the DOMParser. False if the order of the attributes must be stored in a userdata in a node.
        preserveNotNormalizedAttributeValues - True if the not normalized (original) attribute values must be preserved.
        Returns:
        A Xerces DOM parser with some features set and with a fake entity resolver.
        Throws:
        org.xml.sax.SAXException - If the features of the parser could not be set.
      • newXRFullValidIdCollector

        public static org.xml.sax.XMLReader newXRFullValidIdCollector​(java.util.List<ro.sync.xml.parser.IDValue> idValues)
        Creates an XMLReader that collects ID Attributes values with full validation and schema checking, disabled std.output and with no resolver set. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Parameters:
        idValues - The list of ID values to be modified.
        Returns:
        an XMLReader
      • newDTDXRFullValidIdCollector

        public static org.xml.sax.XMLReader newDTDXRFullValidIdCollector​(java.util.List<ro.sync.xml.parser.IDValue> idValues,
                                                                         ro.sync.xml.parser.GrammarCache xgc)
        Creates an XMLReader that collects ID Attributes values with full validation and schema checking, disabled std.output and with no resolver set. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Parameters:
        idValues - The list of ID values to be modified.
        xgc - The XML Grammar cache, if available
        Returns:
        an XMLReader
      • newDTDXRFullValidIdCollector

        public static org.xml.sax.XMLReader newDTDXRFullValidIdCollector​(java.util.List<ro.sync.xml.parser.IDValue> idValues,
                                                                         org.apache.xerces.util.SynchronizedXMLGrammarPoolImpl xgp)
        Creates an XMLReader that collects ID Attributes values with full validation and schema checking, disabled std.output and with no resolver set. The parser is not continuing after fatal error.

        The parser has the catalog entity resolver.

        Parameters:
        idValues - The list of ID values to be modified.
        xgp - The XML Grammar cache, if available
        Returns:
        an XMLReader
      • changeValidationMode

        public static org.xml.sax.XMLReader changeValidationMode​(org.xml.sax.XMLReader parser,
                                                                 int validationMode)
        Changes the validation mode.
        Parameters:
        parser - The xml reader to be changed the mode.
        validationMode - The validation operation.
        Returns:
        The same xmlReader as input.
      • newLocationDomParser

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParser()
        Creates a DOM Parser that populates with location information the nodes.
        Returns:
        The new parser.
      • newLocationDomParser

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParser​(org.apache.xerces.xni.parser.XMLParserConfiguration config,
                                                                                   boolean dtdAware)
        Creates a DOM Parser that populates with location information the nodes. Call LocationDomParser.setInputSource if the parser will be started from the configuration.
        Parameters:
        config - The parser configuration.
        dtdAware - true if the parser is DTD aware.
        Returns:
        The new parser.
      • newLocationDomParserNoResolver

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserNoResolver()
        Creates a DOM parser that has no catalog resolver.
        Returns:
        The new dom parser.
      • newLocationDomParserNoResolverForDiff

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserNoResolverForDiff()
        Creates a DOM parser that has no catalog resolver, no DTD validation for last stage and no RNG defaults processing.
        Returns:
        The new dom parser.
      • setAcceptUndeclaredEntities

        public static void setAcceptUndeclaredEntities​(org.apache.xerces.parsers.DOMParser parser)
        Set accept undeclared entities for the DOM parser.
        Parameters:
        parser - The DOM parser to set the feature on.
      • setParserSystemProperties

        public static void setParserSystemProperties()
        Sets the parser JAXP properties to point to the correct implementation.
      • newLocationDomParserForXpath

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserForXpath()
        Creates a Location DOM Parser that is tuned for XPath. It will expand external entities and store their systemID in the nodes.
        Returns:
        A new location dom parser.
      • newLocationDomParserForXpath

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserForXpath​(ro.sync.basic.execution.ExecutionStopper executionStopper)
        Creates a Location DOM Parser that is tuned for XPath. It will expand external entities and store their systemID in the nodes.
        Parameters:
        executionStopper - The execution stopper. Can be null
        Returns:
        A new location dom parser.
      • newLocationDomParserForXpath

        public static ro.sync.basic.xml.dom.LocationDomParser newLocationDomParserForXpath​(ro.sync.basic.execution.ExecutionStopper executionStopper,
                                                                                           org.apache.xerces.xni.grammars.XMLGrammarPool gp)
        Creates a Location DOM Parser that is tuned for XPath. It will expand external entities and store their systemID in the nodes.
        Parameters:
        executionStopper - The execution stopper. Can be null
        gp - The grammar pool. Can be null
        Returns:
        A new location dom parser.
      • createSchemaValidationPreparser

        public static org.apache.xerces.parsers.XMLGrammarPreparser createSchemaValidationPreparser​(ro.sync.exml.editor.xsdeditor.XMLSchemaVersion schemaVersion)
        Creates a preparser for schema validation.
        Parameters:
        schemaVersion - An XML Schema version.
        Returns:
        A preparser used for XML Schema validation.
      • getXercesSchemaVersionPropertyValue

        public static java.lang.String getXercesSchemaVersionPropertyValue​(ro.sync.exml.editor.xsdeditor.XMLSchemaVersion schemaVersion)
        Converts the given enum constant representing an XML Schema version to a String value to be set for the Xerces property XML_SCHEMA_VERSION.
        Parameters:
        schemaVersion - An XML Schema version.
        Returns:
        String value to be set for the Xerces property XML_SCHEMA_VERSION.
      • getSchemaVersionFromParser

        public static ro.sync.exml.editor.xsdeditor.XMLSchemaVersion getSchemaVersionFromParser​(org.xml.sax.XMLReader parser)
        Gets the schema version set the parser and converts the Xerces schema version, that can be Constants.W3C_XML_SCHEMA11_NS_URI, or Constants.W3C_XML_SCHEMA10_NS_URI, to an XMLSchemaVersion object.
        Parameters:
        parser - The parser to get the schema version from.
        Returns:
        the XML schema version as an XMLSchemaVersion object.
      • createDTDValidationPreparser

        public static org.apache.xerces.parsers.XMLGrammarPreparser createDTDValidationPreparser()
        Creates a preparser for DTD validation.
        Returns:
        A preparser used for DTD validation
      • createMultipleSchemasPreparser

        public static org.apache.xerces.parsers.XMLGrammarPreparser createMultipleSchemasPreparser​(org.xml.sax.InputSource[] sources)
        Gets the XSD's Grammars from XSD Files URLs
        Parameters:
        sources - The URLs
        Returns:
        The Grammar Preparser
      • getXMLInputSource

        public static org.apache.xerces.xni.parser.XMLInputSource getXMLInputSource​(org.xml.sax.InputSource source)
        Carefully creates an XMLInputSource from an InputSource.
        Parameters:
        source - The input source.
        Returns:
        The corresponding xml input source.
      • createCatalogSource

        public static javax.xml.transform.Source createCatalogSource​(javax.xml.transform.Source source)
        Adds an XML reader with a catalog resolver in case of a stream source transforming it into a SAXSource.
        Parameters:
        source - The source.
        Returns:
        A new source or the argument if the input is a DOMSource or a SAXSource.
      • createCatalogSAXSource

        public static javax.xml.transform.sax.SAXSource createCatalogSAXSource​(javax.xml.transform.stream.StreamSource streamSource)
        Create a SAX source starting from a stream source/
        Parameters:
        streamSource - The stream source.
        Returns:
        A SAX source.
      • createGrammarCachedXMLReader

        public static org.xml.sax.XMLReader createGrammarCachedXMLReader​(ro.sync.xml.parser.GrammarCache xgp,
                                                                         boolean valid)
                                                                  throws org.xml.sax.SAXNotRecognizedException,
                                                                         org.xml.sax.SAXNotSupportedException
        Create an XML reader with cached grammar
        Parameters:
        xgp - The grammar pool caching
        valid - True if also validates
        Returns:
        The XML Reader
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • createGrammarCachedXMLReader

        public static org.xml.sax.XMLReader createGrammarCachedXMLReader​(ro.sync.xml.parser.GrammarCache xgp,
                                                                         boolean valid,
                                                                         ro.sync.exml.editor.xsdeditor.XMLSchemaVersion version)
                                                                  throws org.xml.sax.SAXNotRecognizedException,
                                                                         org.xml.sax.SAXNotSupportedException
        Create an XML reader with cached grammar
        Parameters:
        xgp - The grammar pool caching
        valid - True if also validates
        version - The XML Schema version to use. Can be null.
        Returns:
        The XML Reader
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • createXMLGrammarPool

        public static org.apache.xerces.util.SynchronizedXMLGrammarPoolImpl createXMLGrammarPool​(ro.sync.xml.parser.GrammarCache xgp)
        Create the XML Grammar Pool
        Parameters:
        xgp - The XML Grammar Pool cacher.
        Returns:
        The XML Grammar Pool
      • createDOMParser

        public static org.apache.xerces.parsers.DOMParser createDOMParser()
                                                                   throws org.xml.sax.SAXNotRecognizedException,
                                                                          org.xml.sax.SAXNotSupportedException
        Create a DOM parser.
        Returns:
        The DOM Parser.
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • createGrammarCachedDOMParser

        public static org.apache.xerces.parsers.DOMParser createGrammarCachedDOMParser​(ro.sync.xml.parser.GrammarCache xgp)
                                                                                throws org.xml.sax.SAXNotRecognizedException,
                                                                                       org.xml.sax.SAXNotSupportedException
        Create a DOM parser with cached grammar
        Parameters:
        xgp - The grammar pool caching.
        Returns:
        The DOM Parser.
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • setGrammarCacheToParser

        public static void setGrammarCacheToParser​(ro.sync.xml.parser.GrammarCache xgp,
                                                   org.apache.xerces.parsers.DOMParser parser)
                                            throws org.xml.sax.SAXNotRecognizedException,
                                                   org.xml.sax.SAXNotSupportedException
        Set the grammar cache to the parser.
        Parameters:
        xgp - The grammar cache.
        parser - The parser.
        Throws:
        org.xml.sax.SAXNotRecognizedException
        org.xml.sax.SAXNotSupportedException
      • newXRNoValidNoRNGDefaults

        public static org.xml.sax.XMLReader newXRNoValidNoRNGDefaults()
        New XML reader not valid without expansion of default RNG attributes.
        Returns:
        The XML reader
      • newXRNoValid

        public static org.xml.sax.XMLReader newXRNoValid​(ro.sync.xml.parser.GrammarCache grammarCache)
        New XML reader not valid with grammar caching support.
        Parameters:
        grammarCache - The grammar cache
        Returns:
        The XML reader