Package eu.maveniverse.domtrip.sax
Class DomTripXMLReader
- java.lang.Object
-
- eu.maveniverse.domtrip.sax.DomTripXMLReader
-
- All Implemented Interfaces:
org.xml.sax.XMLReader
public class DomTripXMLReader extends java.lang.Object implements org.xml.sax.XMLReaderAnXMLReaderimplementation that reads from a domtripDocument.This class allows a domtrip document to be used as a
SAXSourcefor JAXP interoperability. Whenparse(InputSource)is called, it walks the domtrip document tree and emits SAX events to the registeredContentHandler.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:
DomTripSAXSource,SAXOutputter
-
-
Constructor Summary
Constructors Constructor Description DomTripXMLReader(Document document)Creates a new XMLReader that reads from the given document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.xml.sax.ContentHandlergetContentHandler()DocumentgetDocument()Returns the document backing this reader.org.xml.sax.DTDHandlergetDTDHandler()org.xml.sax.EntityResolvergetEntityResolver()org.xml.sax.ErrorHandlergetErrorHandler()booleangetFeature(java.lang.String name)java.lang.ObjectgetProperty(java.lang.String name)voidparse(java.lang.String systemId)Parses the domtrip document, emitting SAX events to the registered handlers.voidparse(org.xml.sax.InputSource input)Parses the domtrip document, emitting SAX events to the registered handlers.voidsetContentHandler(org.xml.sax.ContentHandler handler)voidsetDTDHandler(org.xml.sax.DTDHandler handler)voidsetEntityResolver(org.xml.sax.EntityResolver resolver)voidsetErrorHandler(org.xml.sax.ErrorHandler handler)voidsetFeature(java.lang.String name, boolean value)voidsetProperty(java.lang.String name, java.lang.Object value)
-
-
-
Constructor Detail
-
DomTripXMLReader
public DomTripXMLReader(Document document)
Creates a new XMLReader that reads from the given document.- Parameters:
document- the document to read- Throws:
java.lang.IllegalArgumentException- if document is null
-
-
Method Detail
-
getDocument
public Document getDocument()
Returns the document backing this reader.- Returns:
- the domtrip document
-
getFeature
public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException- Specified by:
getFeaturein interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedException
-
setFeature
public void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException- Specified by:
setFeaturein interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
getProperty
public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException- Specified by:
getPropertyin interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedException
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException- Specified by:
setPropertyin interfaceorg.xml.sax.XMLReader- Throws:
org.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedException
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
- Specified by:
setEntityResolverin interfaceorg.xml.sax.XMLReader
-
getEntityResolver
public org.xml.sax.EntityResolver getEntityResolver()
- Specified by:
getEntityResolverin interfaceorg.xml.sax.XMLReader
-
setDTDHandler
public void setDTDHandler(org.xml.sax.DTDHandler handler)
- Specified by:
setDTDHandlerin interfaceorg.xml.sax.XMLReader
-
getDTDHandler
public org.xml.sax.DTDHandler getDTDHandler()
- Specified by:
getDTDHandlerin interfaceorg.xml.sax.XMLReader
-
setContentHandler
public void setContentHandler(org.xml.sax.ContentHandler handler)
- Specified by:
setContentHandlerin interfaceorg.xml.sax.XMLReader
-
getContentHandler
public org.xml.sax.ContentHandler getContentHandler()
- Specified by:
getContentHandlerin interfaceorg.xml.sax.XMLReader
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
- Specified by:
setErrorHandlerin interfaceorg.xml.sax.XMLReader
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
- Specified by:
getErrorHandlerin interfaceorg.xml.sax.XMLReader
-
parse
public void parse(org.xml.sax.InputSource input) throws java.io.IOException, org.xml.sax.SAXExceptionParses 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 interfaceorg.xml.sax.XMLReader- Parameters:
input- ignored (document was provided at construction)- Throws:
org.xml.sax.SAXException- if the content handler reports an errorjava.lang.IllegalStateException- if no content handler has been setjava.io.IOException
-
parse
public void parse(java.lang.String systemId) throws java.io.IOException, org.xml.sax.SAXExceptionParses 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 interfaceorg.xml.sax.XMLReader- Parameters:
systemId- ignored- Throws:
org.xml.sax.SAXException- if the content handler reports an errorjava.io.IOException
-
-