SAX {@link XMLReader} implementation that traverses a given OM tree and invokes thecallback methods on the configured {@link ContentHandler}. This can be used to serialize an Axiom tree to SAX.
Note that this class only supports {@link ContentHandler} and {@link LexicalHandler}. {@link DTDHandler} and {@link 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.