Package com.verisign.epp.util
Class EPPSchemaCachingParser
java.lang.Object
javax.xml.parsers.DocumentBuilder
com.verisign.epp.util.EPPSchemaCachingParser
- All Implemented Interfaces:
EPPSchemaCacher
- Direct Known Subclasses:
EPPStrictContactParser,EPPXMLSignatureSchemaCachingParser
XML Parser that pre-caches the XML schemas from the XML schemas registered in
the
EPPFactory for improved XML parsing performance.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA default prime number to use for the SymbolTable size.static final StringCreate EntityReference nodes in the DOM tree.static final StringConstant for setting the defer node expansion parser feature.static final StringIf DTDs (doctypes) are disallowed, almost all XML entity attacks are preventedstatic final StringIf DTDs (doctypes) are disallowed, almost all XML entity attacks are preventedstatic final StringInclude external parameter entities and the external DTD subset.static final StringInclude text nodes that can be considered "ignorable whitespace" in the DOM tree.static final StringLoad the DTD and use it to add default attributes and set attribute types when parsing.static final StringApache constant for loading external DTD's when they are seen in the instance documentstatic final StringNamespaces feature id (http://xml.org/sax/features/namespaces).static final Stringattempt to normalize data in an entity reference or CDATA section.static final StringName of the EPP XML Parser Pool managed byGenericPoolManagerstatic final StringSchema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).static final StringSchema validation feature id (http://apache.org/xml/features/validation/schema).protected static final StringProperty identifier: The symbol table featurestatic final StringValidation feature id (http://xml.org/sax/features/validation).static final StringProperty identifier: The XML Grammar pool feature -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of EPPSchemaCachingParser.EPPSchemaCachingParser(int aSymbolTableSize) Creates an EPPSchemaCachingParser instance with the specified symbol table size. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSchemaToCache(org.apache.xerces.xni.parser.XMLInputSource aSchema) Addes the XMLInputSource instance to the current cache of schemas.Returns the DOM implementationbooleangetFeature(String aFeatureId) Query the state of a feature.getProperty(String aPropertyId) Query the value of a property.intGets the symbol table sizeGets the XML schemas to pre-load into the XML parser.protected voidinit()Helper method to initialize this instance ofEPPSchemaCachingParser.booleanReturns true if the parser is setup to be Namespace aware, false otherwise.booleanReturns true if this parser is setup to validate XML instances, false otherwiseNon-preferred: use the getDOMImplementation() method instead of this one to get a DOM Level 2 DOMImplementation object and then use DOM Level 2 methods to create a DOM Document object.Parse a file to a DOM Document.parse(InputStream aInputStream) Implemented as part of standard Document Builder API.parse(InputStream aInputStream, String aSystemId) Implemented as part of standard Document Builder API.Implemented as part of standard Document Builder API.parse(InputSource aXmlInstance) Parses the InputSource passed in which should be an XML instance.protected voidPre-load the XML schemas into the parser based on theEPPFactoryXML schemas.voidsetEntityResolver(EntityResolver aEntityResolver) Sets the EntityResolver of this DocumentBuildervoidsetErrorHandler(ErrorHandler aErrorHandler) Sets the ErrorHandler this DocumentBuilder instance.voidsetFeature(String aFeatureId, boolean aBoolean) Set the state of any feature in a SAX2 parser.voidsetLockSchemaCache(boolean aBoolean) Lock the schema cache.voidsetProperty(String aProperty, Object aObject) Set the state of any property in a SAX2 parser.voidsetSymbolTableSize(int aSymbolTableSize) Sets the symbol table size.Methods inherited from class javax.xml.parsers.DocumentBuilder
getSchema, isXIncludeAware, reset
-
Field Details
-
POOL
Name of the EPP XML Parser Pool managed byGenericPoolManager- See Also:
-
BIG_PRIME
public static final int BIG_PRIMEA default prime number to use for the SymbolTable size. Some other sample big primes: 1299709 1299721 1299743 1299763 1299791 1299811 1299817 1299821 1299827- See Also:
-
NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces). \- See Also:
-
VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).- See Also:
-
SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).- See Also:
-
SCHEMA_FULL_CHECKING_FEATURE_ID
Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). Enable full schema grammar constraint checking, including checking which may be time-consuming or memory intensive. Currently, particle unique attribution constraint checking and particle derivation resriction checking are controlled by this option.- See Also:
-
XMLGRAMMAR_POOL
Property identifier: The XML Grammar pool feature- See Also:
-
SYMBOL_TABLE
Property identifier: The symbol table feature- See Also:
-
DEFER_NODE_EXPANSION
Constant for setting the defer node expansion parser feature. The recommendation is to set this to false for EPP packets since the are not large documents.- See Also:
-
LOAD_EXTERNAL_DTD
Apache constant for loading external DTD's when they are seen in the instance document- See Also:
-
LOAD_DTD_GRAMMAR
Load the DTD and use it to add default attributes and set attribute types when parsing. False: Build the grammar but do not use the default attributes and attribute types information it contains.- See Also:
-
CREATE_ENTITY_REF_NODES
Create EntityReference nodes in the DOM tree. The EntityReference nodes and their child nodes will be read-only. False: Do not create EntityReference nodes in the DOM tree. No EntityReference nodes will be created, only the nodes corresponding to their fully expanded substitution text will be created- See Also:
-
INCLUDE_IGNORABLE_WHITE_SPACE
Include text nodes that can be considered "ignorable whitespace" in the DOM tree. False: Do not include ignorable whitespace in the DOM tree.- See Also:
-
EXTERNAL_GENERAL_ENTITIES
If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented- See Also:
-
EXTERNAL_PARAMETER_ENTITIES
Include external parameter entities and the external DTD subset. False: Do not include external parameter entities or the external DTD subset.- See Also:
-
NORMALIZE_DATA
attempt to normalize data in an entity reference or CDATA section. To preserve character data within entity references and CDATA sections, turn off http://apache.org/xml/features/validation/schema/normalized-value feature.- See Also:
-
DISALLOW_DOCTYPE_DECL
If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented- See Also:
-
-
Constructor Details
-
EPPSchemaCachingParser
public EPPSchemaCachingParser()Create a new instance of EPPSchemaCachingParser. Defaults are: Namespace aware: true Validation: true Schema Validation: true Full Schema checking: true -
EPPSchemaCachingParser
public EPPSchemaCachingParser(int aSymbolTableSize) Creates an EPPSchemaCachingParser instance with the specified symbol table size.- Parameters:
aSymbolTableSize- Size of the symbol table
-
-
Method Details
-
init
Helper method to initialize this instance ofEPPSchemaCachingParser.- Throws:
EPPParserException- Error initializingEPPSchemaCachingParser
-
getXmlSchemas
Gets the XML schemas to pre-load into the XML parser. Derived classes can override this method to pre-load a custom set of XML schemas.- Returns:
- XML schema names to pre-load
-
preloadSchemas
Pre-load the XML schemas into the parser based on theEPPFactoryXML schemas. A derived class can customize what XML schemas to pre-load.- Throws:
EPPParserException- Error loading the XML schemas into the parser
-
setLockSchemaCache
public void setLockSchemaCache(boolean aBoolean) Lock the schema cache. True param locks it, false unlocks it- Specified by:
setLockSchemaCachein interfaceEPPSchemaCacher- Parameters:
aBoolean- True param locks it, false unlocks it
-
addSchemaToCache
public void addSchemaToCache(org.apache.xerces.xni.parser.XMLInputSource aSchema) throws EPPParserException Addes the XMLInputSource instance to the current cache of schemas. Only addes the schema to the cache if it isn't already in the cache.- Specified by:
addSchemaToCachein interfaceEPPSchemaCacher- Parameters:
aSchema- The schema instance to be cached- Throws:
EPPParserException- Error adding schema to the cache
-
isNamespaceAware
public boolean isNamespaceAware()Returns true if the parser is setup to be Namespace aware, false otherwise.- Specified by:
isNamespaceAwarein classDocumentBuilder- Returns:
- true if the parser is setup to be Namespace aware, false otherwise.
- Throws:
IllegalStateException- Parser is not in a state to query it's properties
-
setEntityResolver
Sets the EntityResolver of this DocumentBuilder- Specified by:
setEntityResolverin classDocumentBuilder- Parameters:
aEntityResolver- The EntityResolver instance that this DocumentBuilder will use when parsing.
-
getDOMImplementation
Returns the DOM implementation- Specified by:
getDOMImplementationin classDocumentBuilder- Returns:
- the DOM implementation
-
newDocument
Non-preferred: use the getDOMImplementation() method instead of this one to get a DOM Level 2 DOMImplementation object and then use DOM Level 2 methods to create a DOM Document object.- Specified by:
newDocumentin classDocumentBuilder- Returns:
- DOM Document
-
parse
Parses the InputSource passed in which should be an XML instance. Returns a DOM document.- Specified by:
parsein classDocumentBuilder- Parameters:
aXmlInstance- The XML instance to parse- Returns:
- The DOM Document that represents the XML instance
- Throws:
SAXException- Thrown if any errors occurIOException- Thrown if any errors occurIllegalArgumentException- DOCUMENT ME!
-
parse
Implemented as part of standard Document Builder API. Delegates to DOMParser- Overrides:
parsein classDocumentBuilder- Parameters:
aInputStream- The InputStream instance to parseaSystemId- XML System Id- Returns:
- The DOM Document created after the parsing episode
- Throws:
SAXException- Error parsing XMLIOException- Error processing input
-
parse
Implemented as part of standard Document Builder API. Delegates to DOMParser- Overrides:
parsein classDocumentBuilder- Parameters:
aUri- The URI to parse- Returns:
- The DOM Document created after the parsing episode
- Throws:
SAXException- Error parsing XMLIOException- Error processing input
-
parse
Implemented as part of standard Document Builder API. Delegates to DOMParser- Overrides:
parsein classDocumentBuilder- Parameters:
aInputStream- The InputStream to parse- Returns:
- The DOM Document created after parsing the stream
- Throws:
SAXException- Error parsing XMLIOException- Error processing input
-
parse
Parse a file to a DOM Document.- Overrides:
parsein classDocumentBuilder- Parameters:
aFile- XML file to parse to a DOM Document- Returns:
- The DOM Document created after parsing the file
- Throws:
IOException- Error opening XML fileSAXException- Error parsing XML file
-
setErrorHandler
Sets the ErrorHandler this DocumentBuilder instance.- Specified by:
setErrorHandlerin classDocumentBuilder- Parameters:
aErrorHandler- The ErrorHandler instance to use
-
isValidating
public boolean isValidating()Returns true if this parser is setup to validate XML instances, false otherwise- Specified by:
isValidatingin classDocumentBuilder- Returns:
- Returns true if this parser is setup to validate XML instances, false otherwise
- Throws:
IllegalStateException- Error setting the validation feature
-
getSymbolTableSize
public int getSymbolTableSize()Gets the symbol table size- Returns:
- the symbol table size
-
setSymbolTableSize
Sets the symbol table size. If set to 0 then the symbol table size will use the default provided with the ParserConfiguration.- Parameters:
aSymbolTableSize- The new value of the symbol table size- Throws:
EPPParserException- Error setting the symbol table size
-
setFeature
public void setFeature(String aFeatureId, boolean aBoolean) throws SAXNotSupportedException, SAXNotRecognizedException Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.- Parameters:
aFeatureId- The unique identifier (URI) of the feature.aBoolean- The requested state of the feature (true or false).- Throws:
SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.SAXNotRecognizedException- If the requested feature is not known.
-
setProperty
public void setProperty(String aProperty, Object aObject) throws SAXNotSupportedException, SAXNotRecognizedException Set the state of any property in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.- Parameters:
aProperty- The unique identifier (URI) of the feature.aObject- The requested state of the feature (true or false).- Throws:
SAXNotSupportedException- If the requested feature is known, but the requested state is not supported.SAXNotRecognizedException- If the requested feature is not known.
-
getFeature
public boolean getFeature(String aFeatureId) throws SAXNotSupportedException, SAXNotRecognizedException Query the state of a feature. Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.- Parameters:
aFeatureId- The unique identifier (URI) of the feature being set.- Returns:
- The current state of the feature.
- Throws:
SAXNotSupportedException- If the requested feature is known but not supported.SAXNotRecognizedException- If the requested feature is not known.
-
getProperty
public Object getProperty(String aPropertyId) throws SAXNotSupportedException, SAXNotRecognizedException Query the value of a property. Return the current value of a property in a SAX2 parser. The parser might not recognize the property.- Parameters:
aPropertyId- The unique identifier (URI) of the property being set.- Returns:
- The current value of the property.
- Throws:
SAXNotSupportedException- If the requested property is known but not supported.SAXNotRecognizedException- If the requested property is not known.
-