Package org.apache.fop.util
Class DOM2SAX
java.lang.Object
org.apache.fop.util.DOM2SAX
Helper class that produces a SAX stream from a DOM Document.
Part of the code here copied and adapted from Apache Xalan-J, src/org/apache/xalan/xsltc/trax/DOM2SAX.java
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ContentHandler
private static final String
private LexicalHandler
private Map
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
endPrefixMapping
(String prefix) private static String
getLocalName
(Node node) If the DOM was created using a DOM 1.0 API, the local name may be null.private boolean
startPrefixMapping
(String prefix, String uri) Begin the scope of namespace prefix.void
writeDocument
(Document doc, boolean fragment) Writes the given document using the given ContentHandler.void
writeFragment
(Node node) Writes the given fragment using the given ContentHandler.private void
Writes a node using the given writer.
-
Field Details
-
EMPTYSTRING
- See Also:
-
XMLNS_PREFIX
- See Also:
-
contentHandler
-
lexicalHandler
-
prefixes
-
-
Constructor Details
-
DOM2SAX
Main constructor- Parameters:
handler
- the ContentHandler to send SAX events to
-
-
Method Details
-
writeDocument
Writes the given document using the given ContentHandler.- Parameters:
doc
- DOM documentfragment
- if false no startDocument() and endDocument() calls are issued.- Throws:
SAXException
- In case of a problem while writing XML
-
writeFragment
Writes the given fragment using the given ContentHandler.- Parameters:
node
- DOM node- Throws:
SAXException
- In case of a problem while writing XML
-
startPrefixMapping
Begin the scope of namespace prefix. Forward the event to the SAX handler only if the prefix is unknown or it is mapped to a different URI.- Throws:
SAXException
-
endPrefixMapping
- Throws:
SAXException
-
getLocalName
If the DOM was created using a DOM 1.0 API, the local name may be null. If so, get the local name from the qualified name before generating the SAX event. -
writeNode
Writes a node using the given writer.- Parameters:
node
- node to serialize- Throws:
SAXException
- In case of a problem while writing XML
-