Class DOM2SAX

java.lang.Object
org.apache.fop.util.DOM2SAX

public class DOM2SAX extends 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 Details

  • Constructor Details

    • DOM2SAX

      public DOM2SAX(ContentHandler handler)
      Main constructor
      Parameters:
      handler - the ContentHandler to send SAX events to
  • Method Details

    • writeDocument

      public void writeDocument(Document doc, boolean fragment) throws SAXException
      Writes the given document using the given ContentHandler.
      Parameters:
      doc - DOM document
      fragment - if false no startDocument() and endDocument() calls are issued.
      Throws:
      SAXException - In case of a problem while writing XML
    • writeFragment

      public void writeFragment(Node node) throws SAXException
      Writes the given fragment using the given ContentHandler.
      Parameters:
      node - DOM node
      Throws:
      SAXException - In case of a problem while writing XML
    • startPrefixMapping

      private boolean startPrefixMapping(String prefix, String uri) throws 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:
      SAXException
    • endPrefixMapping

      private void endPrefixMapping(String prefix) throws SAXException
      Throws:
      SAXException
    • getLocalName

      private static String getLocalName(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(Node node) throws SAXException
      Writes a node using the given writer.
      Parameters:
      node - node to serialize
      Throws:
      SAXException - In case of a problem while writing XML