public class OMXMLReader
extends java.lang.Object
implements org.xml.sax.XMLReader
XMLReader implementation that traverses a given OM tree and invokes the
callback methods on the configured ContentHandler. This can be used to
serialize an Axiom tree to SAX.
Note that this class doesn't support serializing OMDocType
nodes. They will be silently skipped.
This class can also generate SAX events for a subtree. This is the case if the
element passed to the constructor is not the root element of the document. In this
case, care is taken to properly generate startPrefixMapping and
endPrefixMapping events also for namespace mappings declared on the ancestors
of the element.
To understand why this is important, consider the following example:
<root xmlns:ns="urn:ns"><element attr="ns:someThing"/><root>In that case, to correctly interpret the attribute value, the SAX content handler must be aware of the namespace mapping for the ns prefix, even if the serialization starts only at the child element.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
OMXMLReader.AttributesAdapter |
| Constructor and Description |
|---|
OMXMLReader(OMElement element) |
| Modifier and Type | Method and Description |
|---|---|
org.xml.sax.ContentHandler |
getContentHandler() |
org.xml.sax.DTDHandler |
getDTDHandler() |
org.xml.sax.EntityResolver |
getEntityResolver() |
org.xml.sax.ErrorHandler |
getErrorHandler() |
boolean |
getFeature(java.lang.String name) |
java.lang.Object |
getProperty(java.lang.String name) |
void |
parse(org.xml.sax.InputSource input) |
void |
parse(java.lang.String systemId) |
void |
setContentHandler(org.xml.sax.ContentHandler contentHandler) |
void |
setDTDHandler(org.xml.sax.DTDHandler dtdHandler) |
void |
setEntityResolver(org.xml.sax.EntityResolver entityResolver) |
void |
setErrorHandler(org.xml.sax.ErrorHandler errorHandler) |
void |
setFeature(java.lang.String name,
boolean value) |
void |
setProperty(java.lang.String name,
java.lang.Object value) |
public OMXMLReader(OMElement element)
public org.xml.sax.ContentHandler getContentHandler()
getContentHandler in interface org.xml.sax.XMLReaderpublic void setContentHandler(org.xml.sax.ContentHandler contentHandler)
setContentHandler in interface org.xml.sax.XMLReaderpublic org.xml.sax.DTDHandler getDTDHandler()
getDTDHandler in interface org.xml.sax.XMLReaderpublic void setDTDHandler(org.xml.sax.DTDHandler dtdHandler)
setDTDHandler in interface org.xml.sax.XMLReaderpublic org.xml.sax.EntityResolver getEntityResolver()
getEntityResolver in interface org.xml.sax.XMLReaderpublic void setEntityResolver(org.xml.sax.EntityResolver entityResolver)
setEntityResolver in interface org.xml.sax.XMLReaderpublic org.xml.sax.ErrorHandler getErrorHandler()
getErrorHandler in interface org.xml.sax.XMLReaderpublic void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
setErrorHandler in interface org.xml.sax.XMLReaderpublic boolean getFeature(java.lang.String name)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
getFeature in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedExceptionpublic void setFeature(java.lang.String name,
boolean value)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
setFeature in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedExceptionpublic java.lang.Object getProperty(java.lang.String name)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
getProperty in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedExceptionpublic void setProperty(java.lang.String name,
java.lang.Object value)
throws org.xml.sax.SAXNotRecognizedException,
org.xml.sax.SAXNotSupportedException
setProperty in interface org.xml.sax.XMLReaderorg.xml.sax.SAXNotRecognizedExceptionorg.xml.sax.SAXNotSupportedExceptionpublic void parse(org.xml.sax.InputSource input)
throws java.io.IOException,
org.xml.sax.SAXException
parse in interface org.xml.sax.XMLReaderjava.io.IOExceptionorg.xml.sax.SAXExceptionpublic void parse(java.lang.String systemId)
throws java.io.IOException,
org.xml.sax.SAXException
parse in interface org.xml.sax.XMLReaderjava.io.IOExceptionorg.xml.sax.SAXExceptionCopyright © 2004-2015 The Apache Software Foundation. All Rights Reserved.