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

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

public class OMXMLReader
extends Object
implements XMLReader

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


Nested Class Summary
protected static class OMXMLReader.AttributesAdapter
           
 
Constructor Summary
OMXMLReader(OMElement element)
           
 
Method Summary
 ContentHandler getContentHandler()
           
 DTDHandler getDTDHandler()
           
 EntityResolver getEntityResolver()
           
 ErrorHandler getErrorHandler()
           
 boolean getFeature(String name)
           
 Object getProperty(String name)
           
 void parse(InputSource input)
           
 void parse(String systemId)
           
 void setContentHandler(ContentHandler contentHandler)
           
 void setDTDHandler(DTDHandler dtdHandler)
           
 void setEntityResolver(EntityResolver entityResolver)
           
 void setErrorHandler(ErrorHandler errorHandler)
           
 void setFeature(String name, boolean value)
           
 void setProperty(String name, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OMXMLReader

public OMXMLReader(OMElement element)
Method Detail

getContentHandler

public ContentHandler getContentHandler()
Specified by:
getContentHandler in interface XMLReader

setContentHandler

public void setContentHandler(ContentHandler contentHandler)
Specified by:
setContentHandler in interface XMLReader

getDTDHandler

public DTDHandler getDTDHandler()
Specified by:
getDTDHandler in interface XMLReader

setDTDHandler

public void setDTDHandler(DTDHandler dtdHandler)
Specified by:
setDTDHandler in interface XMLReader

getEntityResolver

public EntityResolver getEntityResolver()
Specified by:
getEntityResolver in interface XMLReader

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)
Specified by:
setEntityResolver in interface XMLReader

getErrorHandler

public ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface XMLReader

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Specified by:
setErrorHandler in interface XMLReader

getFeature

public boolean getFeature(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Specified by:
getFeature in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

setFeature

public void setFeature(String name,
                       boolean value)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
Specified by:
setFeature in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

getProperty

public Object getProperty(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Specified by:
getProperty in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

setProperty

public void setProperty(String name,
                        Object value)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Specified by:
setProperty in interface XMLReader
Throws:
SAXNotRecognizedException
SAXNotSupportedException

parse

public void parse(InputSource input)
           throws IOException,
                  SAXException
Specified by:
parse in interface XMLReader
Throws:
IOException
SAXException

parse

public void parse(String systemId)
           throws IOException,
                  SAXException
Specified by:
parse in interface XMLReader
Throws:
IOException
SAXException


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