public class OMXMLReader extends AbstractXMLReader
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 only supports ContentHandler and LexicalHandler.
DTDHandler and DeclHandler are not supported.
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 |
| Modifier and Type | Field and Description |
|---|---|
private OMXMLReader.AttributesAdapter |
attributesAdapter |
private OMContainer |
root |
contentHandler, dtdHandler, entityResolver, errorHandler, lexicalHandler, namespacePrefixes, namespaces| Constructor and Description |
|---|
OMXMLReader(OMContainer root) |
| Modifier and Type | Method and Description |
|---|---|
private void |
generateEvents(OMDocument document) |
private void |
generateEvents(OMElement omElement) |
private void |
generateEvents(OMText omText,
boolean space) |
private void |
generateEventsForChildren(OMContainer parent) |
private void |
generateParentPrefixMappingEvents(OMElement omElement,
boolean start) |
private void |
generatePrefixMappingEvents(OMElement omElement,
boolean start) |
private void |
generatePrefixMappingEvents(OMNamespace ns,
boolean start) |
private void |
parse() |
void |
parse(org.xml.sax.InputSource input) |
void |
parse(java.lang.String systemId) |
getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getProperty, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setPropertyprivate final OMContainer root
private final OMXMLReader.AttributesAdapter attributesAdapter
public OMXMLReader(OMContainer root)
public void parse(org.xml.sax.InputSource input)
throws java.io.IOException,
org.xml.sax.SAXException
java.io.IOExceptionorg.xml.sax.SAXExceptionpublic void parse(java.lang.String systemId)
throws java.io.IOException,
org.xml.sax.SAXException
java.io.IOExceptionorg.xml.sax.SAXExceptionprivate void parse()
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generateEvents(OMDocument document) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generatePrefixMappingEvents(OMNamespace ns, boolean start) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generatePrefixMappingEvents(OMElement omElement, boolean start) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generateParentPrefixMappingEvents(OMElement omElement, boolean start) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generateEvents(OMElement omElement) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generateEventsForChildren(OMContainer parent) throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void generateEvents(OMText omText, boolean space) throws org.xml.sax.SAXException
org.xml.sax.SAXException