Class TreeBuilder

  • All Implemented Interfaces:
    javax.xml.transform.Result, javax.xml.transform.SourceLocator, org.xml.sax.ErrorHandler, org.xml.sax.Locator

    public class TreeBuilder
    extends Builder
    The Builder class is responsible for taking a stream of SAX events and constructing a Document tree.
    Author:
    Michael H. Kay
    • Constructor Detail

      • TreeBuilder

        public TreeBuilder()
        create a Builder and initialise variables
    • Method Detail

      • setNodeFactory

        public void setNodeFactory​(NodeFactory factory)
        Set the Node Factory to use. If none is specified, the Builder uses its own.
      • startDocument

        public void startDocument()
                           throws javax.xml.transform.TransformerException
        Callback interface for SAX: not for application use
        Specified by:
        startDocument in class Emitter
        Throws:
        javax.xml.transform.TransformerException
      • endDocument

        public void endDocument()
                         throws javax.xml.transform.TransformerException
        Callback interface for SAX: not for application use
        Specified by:
        endDocument in class Emitter
        Throws:
        javax.xml.transform.TransformerException
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Callback interface for SAX: not for application use
        Overrides:
        setDocumentLocator in class Emitter
      • startElement

        public void startElement​(int nameCode,
                                 org.xml.sax.Attributes attributes,
                                 int[] namespaces,
                                 int namespacesUsed)
                          throws javax.xml.transform.TransformerException
        Callback interface for SAX: not for application use
        Specified by:
        startElement in class Emitter
        namespaces - Array of namespace codes identifying the namespace prefix/uri pairs associated with this element
        namespacesUsed - Number of significant entries within namespaces array
        Throws:
        javax.xml.transform.TransformerException
      • endElement

        public void endElement​(int nameCode)
                        throws javax.xml.transform.TransformerException
        Callback interface for SAX: not for application use
        Specified by:
        endElement in class Emitter
        Throws:
        javax.xml.transform.TransformerException
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws javax.xml.transform.TransformerException
        Callback interface for SAX: not for application use
        Specified by:
        characters in class Emitter
        Throws:
        javax.xml.transform.TransformerException
      • processingInstruction

        public void processingInstruction​(java.lang.String name,
                                          java.lang.String remainder)
        Callback interface for SAX: not for application use
        Note: because SAX1 does not deliver comment nodes, we get these in the form of a processing instruction with a null name. This requires a specially-adapted SAX driver.
        Specified by:
        processingInstruction in class Emitter
      • comment

        public void comment​(char[] ch,
                            int start,
                            int length)
                     throws javax.xml.transform.TransformerException
        Callback interface for SAX (part of LexicalHandler interface): not for application use
        Specified by:
        comment in class Emitter
        Throws:
        javax.xml.transform.TransformerException
      • graftElement

        public void graftElement​(ElementImpl element)
                          throws javax.xml.transform.TransformerException
        graftElement() allows an element node to be transferred from one tree to another. This is a dangerous internal interface which is used only to contruct a stylesheet tree from a stylesheet using the "literal result element as stylesheet" syntax. The supplied element is grafted onto the current element as its only child.
        Throws:
        javax.xml.transform.TransformerException
      • setUnparsedEntity

        public void setUnparsedEntity​(java.lang.String name,
                                      java.lang.String uri)
        Set an unparsed entity URI for the document
        Specified by:
        setUnparsedEntity in class Builder