Class SAX2DOMConverter

java.lang.Object
eu.bandm.tools.util.xml.SAX2DOMConverter
All Implemented Interfaces:
ContentHandler

public class SAX2DOMConverter extends Object implements ContentHandler
De-Serializes a document given by a sequence of SAX calls into a static w3c dom representation (in some local implementation, accessed via the JAXP architecture).
Usage sequence: (1) call sdc = new SAX2DOMConverter()
(2) call sdc.setDOMImplementation(DOMImplementation)
(For instance fetched from javax.xml.parsers.DocumentBuilderFactory.newInstance() .newDocumentBuilder().getDOMImplementation()
(3) send SAX events to sdc
ATTENTION, document node and top-level element are already built!
(4) finally call sdc.getDocument()
  • Constructor Details

    • SAX2DOMConverter

      public SAX2DOMConverter()
  • Method Details

    • setDOMImplementation

      public void setDOMImplementation(DOMImplementation domImpl)
      Sets the system-dependent factory which will deliver the dom object.
    • getDOMImplementation

      @Opt public @Opt DOMImplementation getDOMImplementation()
      Delivers the system-dependent factory which will deliver the dom object, as set explicityl by a call to setDOMImplementation(org.w3c.dom.DOMImplementation).
    • startDocument

      public void startDocument()
      Creates a new document. No topeleve element ("document element") is created. This is left to the first "open" Sax event.
      Specified by:
      startDocument in interface ContentHandler
    • setDocumentURI

      public void setDocumentURI(String documentUri)
      Set the document URI. The value goes directly to Document and thus is the basis for calculating all relative uris contained in this document. May only be called once for each instance, before or after startDocument().
    • getDocument

      public Document getDocument()
      Deliver the generated dom document. Sensibly called not before the last SAX event has been received.
    • startElement

      public void startElement(String namespaceURI, String localName, String qName, Attributes attrs)
      evident
      Specified by:
      startElement in interface ContentHandler
    • endElement

      public void endElement(String namespaceURI, String localName, String qName)
      evident
      Specified by:
      endElement in interface ContentHandler
    • characters

      public void characters(char[] data, int start, int length)
      evident
      Specified by:
      characters in interface ContentHandler
    • endDocument

      public void endDocument()
      Is ignored by this implementation.
      Specified by:
      endDocument in interface ContentHandler
    • endPrefixMapping

      public void endPrefixMapping(String prefix)
      Is ignored by this implementation. All sax events are assumed to contain complete and consistent namespace information (URI, localname, qname).
      Specified by:
      endPrefixMapping in interface ContentHandler
    • ignorableWhitespace

      public void ignorableWhitespace(char[] data, int start, int length)
      Is ignored by this implementation.
      Specified by:
      ignorableWhitespace in interface ContentHandler
    • processingInstruction

      public void processingInstruction(String target, String text)
      Is ignored by this implementation.
      Specified by:
      processingInstruction in interface ContentHandler
    • skippedEntity

      public void skippedEntity(String name)
      Is ignored by this implementation.
      Specified by:
      skippedEntity in interface ContentHandler
    • setDocumentLocator

      public void setDocumentLocator(Locator locator)
      Is ignored by this implementation.
      Specified by:
      setDocumentLocator in interface ContentHandler
    • startPrefixMapping

      public void startPrefixMapping(String prefix, String namespaceURI)
      Is ignored by this implementation. All sax events are assumed to contain complete and consistent namespace information (URI, localname, qname).
      Specified by:
      startPrefixMapping in interface ContentHandler