|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.xml.AbstractXMLProducer org.apache.cocoon.xml.dom.DOMStreamer.NamespaceNormalizingDOMStreamer
public static class DOMStreamer.NamespaceNormalizingDOMStreamer
Streams a DOM tree to SAX events and normalizes namespace declarations on the way.
The code in this class is based on the org.apache.xml.utils.TreeWalker class from Xalan, though it differs in some important ways.
This class will automatically fix up ("normalize") namespace declarations while streaming to SAX. The original DOM-tree is not modified. The algorithm used is described in an appendix of the DOM Level 3 spec.
This class will NOT check the correctness of namespaces, e.g. it will not check that the "xml" prefix is not misused etc.
Nested Class Summary | |
---|---|
static class |
DOMStreamer.NamespaceNormalizingDOMStreamer.ElementInfo
|
Field Summary | |
---|---|
protected DOMStreamer.NamespaceNormalizingDOMStreamer.ElementInfo |
currentElementInfo
Information about the current element. |
protected int |
newPrefixCounter
Counter used when generating new namespace prefixes. |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
Constructor Summary | |
---|---|
DOMStreamer.NamespaceNormalizingDOMStreamer()
|
Method Summary | |
---|---|
protected void |
endNode(Node node)
End processing of given node |
String |
getNamespaceForPrefix(String prefix,
Element namespaceContext)
Searches the namespace for a given namespace prefix starting from a given Element. |
void |
recycle()
Recycle the producer by removing references, and resetting handlers to null (empty) implementations. |
protected void |
startNode(Node node)
Start processing given node |
protected void |
stream(Node pos)
Start the production of SAX events. |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
setConsumer, setContentHandler, setLexicalHandler |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected DOMStreamer.NamespaceNormalizingDOMStreamer.ElementInfo currentElementInfo
protected int newPrefixCounter
Constructor Detail |
---|
public DOMStreamer.NamespaceNormalizingDOMStreamer()
Method Detail |
---|
public void recycle()
AbstractXMLProducer
recycle
in interface Recyclable
recycle
in class AbstractXMLProducer
protected void stream(Node pos) throws SAXException
Perform a pre-order traversal non-recursive style.
Note that TreeWalker assumes that the subtree is intended to represent a complete (though not necessarily well-formed) document and, during a traversal, startDocument and endDocument will always be issued to the SAX listener.
pos
- Node in the tree where to start traversal
SAXException
protected void startNode(Node node) throws SAXException
node
- Node to process
SAXException
public String getNamespaceForPrefix(String prefix, Element namespaceContext)
Note that this resolves the prefix in the orginal DOM-tree, not in
the DOMStreamer.NamespaceNormalizingDOMStreamer.ElementInfo
objects. This is used to resolve prefixes
of elements or attributes created with createElement or setAttribute
instead of createElementNS or setAttributeNS.
The code in this method is largely based on org.apache.xml.utils.DOMHelper.getNamespaceForPrefix() (from Xalan).
prefix
- the prefix to look for, can be empty or null to find the
default namespace
protected void endNode(Node node) throws SAXException
node
- Node we just finished processing
SAXException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |