org.apache.axiom.om.impl.serialize
Class OMXMLReader

java.lang.Object
  extended by org.apache.axiom.util.sax.AbstractXMLReader
      extended by org.apache.axiom.om.impl.serialize.OMXMLReader
All Implemented Interfaces:
XMLReader

public class OMXMLReader
extends AbstractXMLReader

SAX 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.


Nested Class Summary
protected static class OMXMLReader.AttributesAdapter
           
 
Field Summary
 
Fields inherited from class org.apache.axiom.util.sax.AbstractXMLReader
contentHandler, dtdHandler, entityResolver, errorHandler, lexicalHandler, namespacePrefixes, namespaces
 
Constructor Summary
OMXMLReader(OMContainer root)
           
 
Method Summary
 void parse(InputSource input)
           
 void parse(String systemId)
           
 
Methods inherited from class org.apache.axiom.util.sax.AbstractXMLReader
getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getProperty, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OMXMLReader

public OMXMLReader(OMContainer root)
Method Detail

parse

public void parse(InputSource input)
           throws IOException,
                  SAXException
Throws:
IOException
SAXException

parse

public void parse(String systemId)
           throws IOException,
                  SAXException
Throws:
IOException
SAXException


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.