Package org.apache.fop.util
Class DOM2SAX
- java.lang.Object
-
- org.apache.fop.util.DOM2SAX
-
public class DOM2SAX extends java.lang.Object
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
Fields Modifier and Type Field Description private org.xml.sax.ContentHandler
contentHandler
private static java.lang.String
EMPTYSTRING
private org.xml.sax.ext.LexicalHandler
lexicalHandler
private java.util.Map
prefixes
private static java.lang.String
XMLNS_PREFIX
-
Constructor Summary
Constructors Constructor Description DOM2SAX(org.xml.sax.ContentHandler handler)
Main constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
endPrefixMapping(java.lang.String prefix)
private static java.lang.String
getLocalName(org.w3c.dom.Node node)
If the DOM was created using a DOM 1.0 API, the local name may be null.private boolean
startPrefixMapping(java.lang.String prefix, java.lang.String uri)
Begin the scope of namespace prefix.void
writeDocument(org.w3c.dom.Document doc, boolean fragment)
Writes the given document using the given ContentHandler.void
writeFragment(org.w3c.dom.Node node)
Writes the given fragment using the given ContentHandler.private void
writeNode(org.w3c.dom.Node node)
Writes a node using the given writer.
-
-
-
Field Detail
-
EMPTYSTRING
private static final java.lang.String EMPTYSTRING
- See Also:
- Constant Field Values
-
XMLNS_PREFIX
private static final java.lang.String XMLNS_PREFIX
- See Also:
- Constant Field Values
-
contentHandler
private org.xml.sax.ContentHandler contentHandler
-
lexicalHandler
private org.xml.sax.ext.LexicalHandler lexicalHandler
-
prefixes
private java.util.Map prefixes
-
-
Method Detail
-
writeDocument
public void writeDocument(org.w3c.dom.Document doc, boolean fragment) throws org.xml.sax.SAXException
Writes the given document using the given ContentHandler.- Parameters:
doc
- DOM documentfragment
- if false no startDocument() and endDocument() calls are issued.- Throws:
org.xml.sax.SAXException
- In case of a problem while writing XML
-
writeFragment
public void writeFragment(org.w3c.dom.Node node) throws org.xml.sax.SAXException
Writes the given fragment using the given ContentHandler.- Parameters:
node
- DOM node- Throws:
org.xml.sax.SAXException
- In case of a problem while writing XML
-
startPrefixMapping
private boolean startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException
-
endPrefixMapping
private void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
- Throws:
org.xml.sax.SAXException
-
getLocalName
private static java.lang.String getLocalName(org.w3c.dom.Node node)
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
private void writeNode(org.w3c.dom.Node node) throws org.xml.sax.SAXException
Writes a node using the given writer.- Parameters:
node
- node to serialize- Throws:
org.xml.sax.SAXException
- In case of a problem while writing XML
-
-