Package com.icl.saxon
Class DOMDriver
- java.lang.Object
-
- com.icl.saxon.DOMDriver
-
- Direct Known Subclasses:
TreeDriver
public class DOMDriver extends Object implements Locator, XMLReader
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHandlercontentHandlerprotected Noderootprotected StringsystemId
-
Constructor Summary
Constructors Constructor Description DOMDriver()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intgetColumnNumber()ContentHandlergetContentHandler()DTDHandlergetDTDHandler()SAX2: Returns the object used to process declarations related to notations and unparsed entities.EntityResolvergetEntityResolver()SAX2: Returns the object used when resolving external entities during parsing (both general and parameter entities).ErrorHandlergetErrorHandler()SAX2: Returns the object used to receive callbacks for XML errors of all levels (fatal, nonfatal, warning); this is never null;booleangetFeature(String featureId)SAX2: Tells the value of the specified feature flag.intgetLineNumber()ObjectgetProperty(String name)SAX2: Returns the specified property.StringgetPublicId()StringgetSystemId()voidparse()Walk a document (traversing the nodes depth first)voidparse(String source)Parse from SystemId.voidparse(InputSource source)Parse from InputSource.voidsetContentHandler(ContentHandler handler)Set the content handler.voidsetDocumentHandler(DocumentHandler handler)Deprecated.SAX2 programs should use the XMLReader interface and a ContentHandler.voidsetDTDHandler(DTDHandler handler)SAX1, SAX2: Set the DTD handler for this parser.voidsetEntityResolver(EntityResolver resolver)SAX1, SAX2: Set the entity resolver for this parser.voidsetErrorHandler(ErrorHandler handler)SAX1, SAX2: Set the error handler for this parser.voidsetFeature(String featureId, boolean on)SAX2: Sets the state of feature flags in this parser.voidsetLocale(Locale locale)SAX1: Sets the locale used for diagnostics; currently, only locales using the English language are supported.voidsetProperty(String propertyId, Object property)SAX2: Assigns the specified property.voidsetStartNode(Node start)Set the DOM Document that will be walkedvoidsetSystemId(String systemId)
-
-
-
Field Detail
-
contentHandler
protected ContentHandler contentHandler
-
root
protected Node root
-
systemId
protected String systemId
-
-
Method Detail
-
setContentHandler
public void setContentHandler(ContentHandler handler)
Set the content handler.- Specified by:
setContentHandlerin interfaceXMLReader- Parameters:
handler- The object to receive content events. If this also implements LexicalHandler, it will also be notified of comments.
-
getContentHandler
public ContentHandler getContentHandler()
- Specified by:
getContentHandlerin interfaceXMLReader
-
setLocale
public void setLocale(Locale locale) throws SAXException
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
public EntityResolver getEntityResolver()
SAX2: Returns the object used when resolving external entities during parsing (both general and parameter entities).- Specified by:
getEntityResolverin interfaceXMLReader
-
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
SAX1, SAX2: Set the entity resolver for this parser.- Specified by:
setEntityResolverin interfaceXMLReader- Parameters:
resolver- The object to receive entity events.
-
getDTDHandler
public DTDHandler getDTDHandler()
SAX2: Returns the object used to process declarations related to notations and unparsed entities.- Specified by:
getDTDHandlerin interfaceXMLReader
-
setDTDHandler
public void setDTDHandler(DTDHandler handler)
SAX1, SAX2: Set the DTD handler for this parser.- Specified by:
setDTDHandlerin interfaceXMLReader- Parameters:
handler- The object to receive DTD events.
-
setDocumentHandler
public void setDocumentHandler(DocumentHandler handler)
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
public void setErrorHandler(ErrorHandler handler)
SAX1, SAX2: Set the error handler for this parser.- Specified by:
setErrorHandlerin interfaceXMLReader- Parameters:
handler- The object to receive error events.
-
getErrorHandler
public ErrorHandler getErrorHandler()
SAX2: Returns the object used to receive callbacks for XML errors of all levels (fatal, nonfatal, warning); this is never null;- Specified by:
getErrorHandlerin interfaceXMLReader
-
setStartNode
public void setStartNode(Node start)
Set the DOM Document that will be walked
-
parse
public void parse(InputSource source) throws SAXException
Parse from InputSource. The InputSource is ignored; it's there only to satisfy the XMLReader interface- Specified by:
parsein interfaceXMLReader- Throws:
SAXException
-
parse
public void parse(String source) throws SAXException
Parse from SystemId. The SystemId is ignored; it's there only to satisfy the XMLReader interface- Specified by:
parsein interfaceXMLReader- Throws:
SAXException
-
parse
public void parse() throws SAXExceptionWalk a document (traversing the nodes depth first)- Throws:
SAXException- On any error in the document
-
setSystemId
public void setSystemId(String systemId)
-
getPublicId
public String getPublicId()
- Specified by:
getPublicIdin interfaceLocator
-
getSystemId
public String getSystemId()
- Specified by:
getSystemIdin interfaceLocator
-
getLineNumber
public int getLineNumber()
- Specified by:
getLineNumberin interfaceLocator
-
getColumnNumber
public int getColumnNumber()
- Specified by:
getColumnNumberin interfaceLocator
-
getFeature
public boolean getFeature(String featureId) throws SAXNotRecognizedException
SAX2: Tells the value of the specified feature flag.- Specified by:
getFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedException- thrown if the feature flag is neither built in, nor yet assigned.
-
getProperty
public Object getProperty(String name) throws SAXNotRecognizedException
SAX2: Returns the specified property.- Specified by:
getPropertyin 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:
setFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
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:
setPropertyin interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
-