Package ro.sync.xml.parser
Class ParserCreator
java.lang.Object
ro.sync.xml.parser.ParserCreator
Creates all the parsers from the system. All have catalog resolvers, except the ones with
specified FakeResolver.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Feature identifier: Enables comments and PIs for assertions processingstatic final String
Feature identifier: base uri fixup.static final String
Feature identifier: Full XPath 2.0 for CTA evaluationsstatic final int
Check that the document is conformant to a strict set of rules.static final int
If the document declares the use of a schema, then it will be used validation, otherwise only a wellformed check will be done.static final int
Check if the document is conformant to a relaxed set of rules.static final String
Feature identifier: XInclude processingstatic final String
The XML schema version Xerces parser property -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic XMLReader
changeValidationMode
(XMLReader parser, int validationMode) Changes the validation mode.static SAXSource
createCatalogSAXSource
(StreamSource streamSource) Create a SAX source starting from a stream source/static Source
createCatalogSource
(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
Create a DOM parser.static org.apache.xerces.parsers.XMLGrammarPreparser
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 grammarstatic XMLReader
createGrammarCachedXMLReader
(ro.sync.xml.parser.GrammarCache xgp, boolean valid) Create an XML reader with cached grammarstatic XMLReader
createGrammarCachedXMLReader
(ro.sync.xml.parser.GrammarCache xgp, boolean valid, ro.sync.exml.editor.xsdeditor.XMLSchemaVersion version) Create an XML reader with cached grammarstatic org.apache.xerces.parsers.XMLGrammarPreparser
createMultipleSchemasPreparser
(InputSource[] sources) Gets the XSD's Grammars from XSD Files URLsstatic 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 Poolstatic ro.sync.exml.editor.xsdeditor.XMLSchemaVersion
getSchemaVersionFromParser
(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 anXMLSchemaVersion
object.static String
getXercesSchemaVersionPropertyValue
(ro.sync.exml.editor.xsdeditor.XMLSchemaVersion schemaVersion) Converts the givenenum
constant representing an XML Schema version to aString
value to be set for the Xerces propertyXML_SCHEMA_VERSION
.static org.apache.xerces.xni.parser.XMLInputSource
getXMLInputSource
(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 DocumentBuilder
Creates a document buider with a catalog reslover.static DocumentBuilder
newDocumentBuilder
(boolean fakeResolver, boolean noExpand, boolean namespaceAware) Create a document builder.static DocumentBuilder
newDocumentBuilder
(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl) Create a document builder.static DocumentBuilder
newDocumentBuilder
(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl, boolean schemaAware) Create a document builder.static DocumentBuilder
newDocumentBuilder
(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl, boolean schemaAware, boolean forceXIncludeAndBaseURIFixup) Create a document builder.static DocumentBuilder
newDocumentBuilder
(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl, boolean schemaAware, boolean forceXIncludeAndBaseURIFixup, boolean dynamicValidation) Create a document builder.static DocumentBuilder
Creates a document buider with a fake resolver.static DocumentBuilder
Creates a document buider with a catalog reslover.static DocumentBuilder
Creates a document builder which is namespace aware.static XMLReader
newDTDXRFullValidIdCollector
(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 XMLReader
newDTDXRFullValidIdCollector
(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
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
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
Creates a DOM parser that has no catalog resolver.static ro.sync.basic.xml.dom.LocationDomParser
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
(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
(ErrorHandler errorHandler, boolean useCompactSyntax, 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
(ErrorHandler errorHandler, boolean useCompactSyntax, 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
(ErrorHandler errorHandler, boolean useCompactSyntax) Creates a Relax NG validation engine to validate against schemas in XML or compact syntax.static DocumentBuilder
Creates a document buider with a catalog resolver.static 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, 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, 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, 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 XMLReader
Creates a XMLReader with full validation and schema checking, disabled std.output and with no resolver set.static 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 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 XMLReader
newXRFullValidCompoundResolver
(EntityResolver entityResolver) Creates a XMLReader with disabled std.output and a compond resolver, from the catalog resolver and the given resolver.static XMLReader
newXRFullValidIdCollector
(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 XMLReader
Creates a XMLReader with disabled std.output and with no extra resolver.static XMLReader
newXRNoValid
(org.apache.xerces.xni.grammars.XMLGrammarPool gp) Creates a XMLReader with disabled std.output and with no extra resolver.static XMLReader
newXRNoValid
(ro.sync.xml.parser.GrammarCache grammarCache) New XML reader not valid with grammar caching support.static XMLReader
newXRNoValidCompoundResolver
(EntityResolver entityResolver) Creates a XMLReader with disabled std.output and a compound resolver, from the catalog resolver and the given resolver.static XMLReader
Creates a XMLReader with disabled std.output and with a fake resolver.static XMLReader
New XML reader not valid without expansion of default RNG attributes.static 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
Sets the parser JAXP properties to point to the correct implementation.
-
Field Details
-
XINCLUDE_FEATURE
Feature identifier: XInclude processing- See Also:
-
BASE_URI_FIXUP
Feature identifier: base uri fixup.- See Also:
-
VALIDATE
public static final int VALIDATECheck 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:
-
WELLFORMED
public static final int WELLFORMEDCheck if the document is conformant to a relaxed set of rules. See the well formed on XML.- See Also:
-
VALIDATE_OR_WELLFORMED
public static final int VALIDATE_OR_WELLFORMEDIf the document declares the use of a schema, then it will be used validation, otherwise only a wellformed check will be done.- See Also:
-
XML_SCHEMA_VERSION
The XML schema version Xerces parser property- See Also:
-
CTA_FULL_XPATH_FEATURE_ID
Feature identifier: Full XPath 2.0 for CTA evaluations- See Also:
-
ASSERT_COMMENT_PI_CHECKING_ID
Feature identifier: Enables comments and PIs for assertions processing- See Also:
-
-
Constructor Details
-
ParserCreator
public ParserCreator()
-
-
Method Details
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(boolean fakeResolver, boolean noExpand, boolean namespaceAware) throws ParserConfigurationException Create a document builder.- Parameters:
fakeResolver
-true
if a fake resolver should be used as an entity resolver. Iffalse
it will use oxygen catalog an entity resolver from CatalogResolverFactory.noExpand
- Iftrue
the entities will not be expanded.namespaceAware
-true
to activate namespace awareness.- Returns:
- A document builder.
- Throws:
ParserConfigurationException
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl) throws ParserConfigurationException Create a document builder.- Parameters:
fakeResolver
-true
if a fake resolver should be used as an entity resolver. Iffalse
it will use oxygen catalog an entity resolver from CatalogResolverFactory.noExpand
- Iftrue
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:
ParserConfigurationException
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl, boolean schemaAware) throws ParserConfigurationException Create a document builder.- Parameters:
fakeResolver
-true
if a fake resolver should be used as an entity resolver. Iffalse
it will use oxygen catalog an entity resolver from CatalogResolverFactory.noExpand
- Iftrue
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:
ParserConfigurationException
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl, boolean schemaAware, boolean forceXIncludeAndBaseURIFixup) throws ParserConfigurationException Create a document builder.- Parameters:
fakeResolver
-true
if a fake resolver should be used as an entity resolver. Iffalse
it will use oxygen catalog an entity resolver from CatalogResolverFactory.noExpand
- Iftrue
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 awareforceXIncludeAndBaseURIFixup
-true
if the XInclude support must be enabled no matter the options. Base URI fixup will also be enabled.- Returns:
- A document builder.
- Throws:
ParserConfigurationException
-
newDocumentBuilder
public static DocumentBuilder newDocumentBuilder(boolean fakeResolver, boolean noExpand, boolean namespaceAware, URL schemaUrl, boolean schemaAware, boolean forceXIncludeAndBaseURIFixup, boolean dynamicValidation) throws ParserConfigurationException Create a document builder.- Parameters:
fakeResolver
-true
if a fake resolver should be used as an entity resolver. Iffalse
it will use oxygen catalog an entity resolver from CatalogResolverFactory.noExpand
- Iftrue
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 awareforceXIncludeAndBaseURIFixup
-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:
ParserConfigurationException
-
newSchemaAwareDocumentBuilder
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:
ParserConfigurationException
- When the parsers are not conf. properly.
-
newDocumentBuilder
Creates a document buider with a catalog reslover.- Returns:
- The Document Builder
- Throws:
ParserConfigurationException
- When the parsers are not conf. properly.
-
newDocumentBuilderFakeResolver
Creates a document buider with a fake resolver.- Returns:
- The Document Builder
- Throws:
ParserConfigurationException
- When the parsers are not conf. properly.
-
newDocumentBuilderNoExpand
Creates a document buider with a catalog reslover. Does not expand external entities.- Returns:
- The Document Builder
- Throws:
ParserConfigurationException
- When the parsers are not conf. properly.
-
newDocumentBuilderNS
Creates a document builder which is namespace aware. Attaches a catalog resolver to it.- Returns:
- a new DocumentBuilder
- Throws:
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, 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, 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, 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
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
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
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
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
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
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
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 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
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
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(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(ErrorHandler errorHandler, boolean useCompactSyntax, 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(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(ErrorHandler errorHandler, boolean useCompactSyntax, 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 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:
SAXException
- If the features of the parser could not be set.
-
newXRFullValidIdCollector
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 XMLReader newDTDXRFullValidIdCollector(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 XMLReader newDTDXRFullValidIdCollector(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
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 benull
- 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 benull
gp
- The grammar pool. Can benull
- 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 String getXercesSchemaVersionPropertyValue(ro.sync.exml.editor.xsdeditor.XMLSchemaVersion schemaVersion) Converts the givenenum
constant representing an XML Schema version to aString
value to be set for the Xerces propertyXML_SCHEMA_VERSION
.- Parameters:
schemaVersion
- An XML Schema version.- Returns:
String
value to be set for the Xerces propertyXML_SCHEMA_VERSION
.
-
getSchemaVersionFromParser
public static ro.sync.exml.editor.xsdeditor.XMLSchemaVersion getSchemaVersionFromParser(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 anXMLSchemaVersion
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(InputSource[] sources) Gets the XSD's Grammars from XSD Files URLs- Parameters:
sources
- The URLs- Returns:
- The Grammar Preparser
-
getXMLInputSource
Carefully creates an XMLInputSource from an InputSource.- Parameters:
source
- The input source.- Returns:
- The corresponding xml input source.
-
createCatalogSource
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
Create a SAX source starting from a stream source/- Parameters:
streamSource
- The stream source.- Returns:
- A SAX source.
-
createGrammarCachedXMLReader
public static XMLReader createGrammarCachedXMLReader(ro.sync.xml.parser.GrammarCache xgp, boolean valid) throws SAXNotRecognizedException, SAXNotSupportedException Create an XML reader with cached grammar- Parameters:
xgp
- The grammar pool cachingvalid
- True if also validates- Returns:
- The XML Reader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
createGrammarCachedXMLReader
public static XMLReader createGrammarCachedXMLReader(ro.sync.xml.parser.GrammarCache xgp, boolean valid, ro.sync.exml.editor.xsdeditor.XMLSchemaVersion version) throws SAXNotRecognizedException, SAXNotSupportedException Create an XML reader with cached grammar- Parameters:
xgp
- The grammar pool cachingvalid
- True if also validatesversion
- The XML Schema version to use. Can benull
.- Returns:
- The XML Reader
- Throws:
SAXNotRecognizedException
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 SAXNotRecognizedException, SAXNotSupportedExceptionCreate a DOM parser.- Returns:
- The DOM Parser.
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
createGrammarCachedDOMParser
public static org.apache.xerces.parsers.DOMParser createGrammarCachedDOMParser(ro.sync.xml.parser.GrammarCache xgp) throws SAXNotRecognizedException, SAXNotSupportedException Create a DOM parser with cached grammar- Parameters:
xgp
- The grammar pool caching.- Returns:
- The DOM Parser.
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setGrammarCacheToParser
public static void setGrammarCacheToParser(ro.sync.xml.parser.GrammarCache xgp, org.apache.xerces.parsers.DOMParser parser) throws SAXNotRecognizedException, SAXNotSupportedException Set the grammar cache to the parser.- Parameters:
xgp
- The grammar cache.parser
- The parser.- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
newXRNoValidNoRNGDefaults
New XML reader not valid without expansion of default RNG attributes.- Returns:
- The XML reader
-
newXRNoValid
New XML reader not valid with grammar caching support.- Parameters:
grammarCache
- The grammar cache- Returns:
- The XML reader
-