Package com.icl.saxon
Class DOMDriver
java.lang.Object
com.icl.saxon.DOMDriver
- Direct Known Subclasses:
TreeDriver
DOMDriver.java: (pseudo-)SAX driver for DOM.
This class simulates the action of a SAX Parser, taking an already-constructed DOM Document and walking around it in a depth-first traversal, calling a SAX-compliant ContentHandler to process the children as it does so.
This class simulates the action of a SAX Parser, taking an already-constructed DOM Document and walking around it in a depth-first traversal, calling a SAX-compliant ContentHandler to process the children as it does so.
- Version:
- 20 Jan 1999 modified to use AttributeListWrapper class, 3 February 2000 modified to use AttributeCollection class, 24 February 2000 modified to drive SAX2, which means it has to do namespace handling
- Author:
- MHK, 5 Jun 1998
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContentHandler
(package private) static final String
(package private) static final String
protected Node
protected String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
SAX2: Returns the object used to process declarations related to notations and unparsed entities.SAX2: Returns the object used when resolving external entities during parsing (both general and parameter entities).SAX2: Returns the object used to receive callbacks for XML errors of all levels (fatal, nonfatal, warning); this is never null;boolean
getFeature
(String featureId) SAX2: Tells the value of the specified feature flag.int
getProperty
(String name) SAX2: Returns the specified property.void
parse()
Walk a document (traversing the nodes depth first)void
Parse from SystemId.void
parse
(InputSource source) Parse from InputSource.void
setContentHandler
(ContentHandler handler) Set the content handler.void
setDocumentHandler
(DocumentHandler handler) Deprecated.SAX2 programs should use the XMLReader interface and a ContentHandler.void
setDTDHandler
(DTDHandler handler) SAX1, SAX2: Set the DTD handler for this parser.void
setEntityResolver
(EntityResolver resolver) SAX1, SAX2: Set the entity resolver for this parser.void
setErrorHandler
(ErrorHandler handler) SAX1, SAX2: Set the error handler for this parser.void
setFeature
(String featureId, boolean on) SAX2: Sets the state of feature flags in this parser.void
SAX1: Sets the locale used for diagnostics; currently, only locales using the English language are supported.void
setProperty
(String propertyId, Object property) SAX2: Assigns the specified property.void
setStartNode
(Node start) Set the DOM Document that will be walkedvoid
setSystemId
(String systemId)
-
Field Details
-
contentHandler
-
root
-
systemId
-
FEATURE
- See Also:
-
HANDLER
- See Also:
-
-
Constructor Details
-
DOMDriver
public DOMDriver()
-
-
Method Details
-
setContentHandler
Set the content handler.- Specified by:
setContentHandler
in interfaceXMLReader
- Parameters:
handler
- The object to receive content events. If this also implements LexicalHandler, it will also be notified of comments.
-
getContentHandler
- Specified by:
getContentHandler
in interfaceXMLReader
-
setLocale
SAX1: Sets the locale used for diagnostics; currently, only locales using the English language are supported.- Parameters:
locale
- The locale for which diagnostics will be generated- Throws:
SAXException
-
getEntityResolver
SAX2: Returns the object used when resolving external entities during parsing (both general and parameter entities).- Specified by:
getEntityResolver
in interfaceXMLReader
-
setEntityResolver
SAX1, SAX2: Set the entity resolver for this parser.- Specified by:
setEntityResolver
in interfaceXMLReader
- Parameters:
resolver
- The object to receive entity events.
-
getDTDHandler
SAX2: Returns the object used to process declarations related to notations and unparsed entities.- Specified by:
getDTDHandler
in interfaceXMLReader
-
setDTDHandler
SAX1, SAX2: Set the DTD handler for this parser.- Specified by:
setDTDHandler
in interfaceXMLReader
- Parameters:
handler
- The object to receive DTD events.
-
setDocumentHandler
Deprecated.SAX2 programs should use the XMLReader interface and a ContentHandler.SAX1: Set the document handler for this parser. If a content handler was set, this document handler will supplant it. The parser is set to report all XML 1.0 names rather than to filter out "xmlns" attributes (the "namespace-prefixes" feature is set to true).- Parameters:
handler
- The object to receive document events.
-
setErrorHandler
SAX1, SAX2: Set the error handler for this parser.- Specified by:
setErrorHandler
in interfaceXMLReader
- Parameters:
handler
- The object to receive error events.
-
getErrorHandler
SAX2: Returns the object used to receive callbacks for XML errors of all levels (fatal, nonfatal, warning); this is never null;- Specified by:
getErrorHandler
in interfaceXMLReader
-
setStartNode
Set the DOM Document that will be walked -
parse
Parse from InputSource. The InputSource is ignored; it's there only to satisfy the XMLReader interface- Specified by:
parse
in interfaceXMLReader
- Throws:
SAXException
-
parse
Parse from SystemId. The SystemId is ignored; it's there only to satisfy the XMLReader interface- Specified by:
parse
in interfaceXMLReader
- Throws:
SAXException
-
parse
Walk a document (traversing the nodes depth first)- Throws:
SAXException
- On any error in the document
-
setSystemId
-
getPublicId
- Specified by:
getPublicId
in interfaceLocator
-
getSystemId
- Specified by:
getSystemId
in interfaceLocator
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumber
in interfaceLocator
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumber
in interfaceLocator
-
getFeature
SAX2: Tells the value of the specified feature flag.- Specified by:
getFeature
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
- thrown if the feature flag is neither built in, nor yet assigned.
-
getProperty
SAX2: Returns the specified property.- Specified by:
getProperty
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
- thrown if the property value is neither built in, nor yet stored.
-
setFeature
public void setFeature(String featureId, boolean on) throws SAXNotRecognizedException, SAXNotSupportedException SAX2: Sets the state of feature flags in this parser. Some built-in feature flags are mutable; all flags not built-in are motable.- Specified by:
setFeature
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-
setProperty
public void setProperty(String propertyId, Object property) throws SAXNotRecognizedException, SAXNotSupportedException SAX2: Assigns the specified property. Like SAX1 handlers, these may be changed at any time.- Specified by:
setProperty
in interfaceXMLReader
- Throws:
SAXNotRecognizedException
SAXNotSupportedException
-