Class DomTripXMLReader
java.lang.Object
eu.maveniverse.domtrip.sax.DomTripXMLReader
- All Implemented Interfaces:
XMLReader
An
XMLReader implementation that reads from a domtrip Document.
This class allows a domtrip document to be used as a SAXSource
for JAXP interoperability. When parse(InputSource) is called, it walks the
domtrip document tree and emits SAX events to the registered ContentHandler.
Supported Features:
http://xml.org/sax/features/namespaces- alwaystruehttp://xml.org/sax/features/namespace-prefixes- controls whether namespace declarations are reported as attributes (defaultfalse)
Supported Properties:
http://xml.org/sax/properties/lexical-handler-LexicalHandlerfor comment and CDATA events
- Since:
- 1.3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDomTripXMLReader(Document document) Creates a new XMLReader that reads from the given document. -
Method Summary
Modifier and TypeMethodDescriptionReturns the document backing this reader.booleangetFeature(String name) getProperty(String name) voidParses the domtrip document, emitting SAX events to the registered handlers.voidparse(InputSource input) Parses the domtrip document, emitting SAX events to the registered handlers.voidsetContentHandler(ContentHandler handler) voidsetDTDHandler(DTDHandler handler) voidsetEntityResolver(EntityResolver resolver) voidsetErrorHandler(ErrorHandler handler) voidsetFeature(String name, boolean value) voidsetProperty(String name, Object value)
-
Constructor Details
-
DomTripXMLReader
Creates a new XMLReader that reads from the given document.- Parameters:
document- the document to read- Throws:
IllegalArgumentException- if document is null
-
-
Method Details
-
getDocument
Returns the document backing this reader.- Returns:
- the domtrip document
-
getFeature
- Specified by:
getFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedException
-
setFeature
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException - Specified by:
setFeaturein interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
getProperty
- Specified by:
getPropertyin interfaceXMLReader- Throws:
SAXNotRecognizedException
-
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException - Specified by:
setPropertyin interfaceXMLReader- Throws:
SAXNotRecognizedExceptionSAXNotSupportedException
-
setEntityResolver
- Specified by:
setEntityResolverin interfaceXMLReader
-
getEntityResolver
- Specified by:
getEntityResolverin interfaceXMLReader
-
setDTDHandler
- Specified by:
setDTDHandlerin interfaceXMLReader
-
getDTDHandler
- Specified by:
getDTDHandlerin interfaceXMLReader
-
setContentHandler
- Specified by:
setContentHandlerin interfaceXMLReader
-
getContentHandler
- Specified by:
getContentHandlerin interfaceXMLReader
-
setErrorHandler
- Specified by:
setErrorHandlerin interfaceXMLReader
-
getErrorHandler
- Specified by:
getErrorHandlerin interfaceXMLReader
-
parse
Parses the domtrip document, emitting SAX events to the registered handlers.The
inputparameter is ignored since the document is provided at construction time. AContentHandlermust be set before calling this method.- Specified by:
parsein interfaceXMLReader- Parameters:
input- ignored (document was provided at construction)- Throws:
SAXException- if the content handler reports an errorIllegalStateException- if no content handler has been setIOException
-
parse
Parses the domtrip document, emitting SAX events to the registered handlers.The
systemIdparameter is ignored since the document is provided at construction time.- Specified by:
parsein interfaceXMLReader- Parameters:
systemId- ignored- Throws:
SAXException- if the content handler reports an errorIOException
-