net.sf.saxon.tree

Class TreeBuilder

Implemented Interfaces:
Receiver, Result

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

Field Summary

Fields inherited from class net.sf.saxon.event.Builder

LINKED_TREE, STANDARD_TREE, TINY_TREE, UNSPECIFIED_TREE_MODEL, baseURI, config, currentRoot, lineNumbering, namePool, pipe, started, systemId, timing

Constructor Summary

TreeBuilder()
create a Builder and initialise variables

Method Summary

void
attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
void
characters(CharSequence chars, int locationId, int properties)
Notify a text node.
void
close()
Callback interface for SAX: not for application use
void
comment(CharSequence chars, int locationId, int properties)
Notify a comment
void
endElement()
Notify the end of an element
void
graftElement(ElementImpl element)
graftElement() allows an element node to be transferred from one tree to another.
void
namespace(int namespaceCode, int properties)
void
open()
Callback interface for SAX: not for application use
void
processingInstruction(String name, CharSequence remainder, int locationId, int properties)
Notify a processing instruction
void
setNodeFactory(NodeFactory factory)
Set the Node Factory to use.
void
setUnparsedEntity(String name, String uri, String publicId)
Set an unparsed entity URI for the document
void
startContent()
void
startElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element

Methods inherited from class net.sf.saxon.event.Builder

build, build, close, endDocument, getBaseURI, getConfiguration, getCurrentRoot, getPipelineConfiguration, getSystemId, isTiming, open, setBaseURI, setLineNumbering, setPipelineConfiguration, setSystemId, setTiming, startDocument

Constructor Details

TreeBuilder

public TreeBuilder()
create a Builder and initialise variables

Method Details

attribute

public void attribute(int nameCode,
                      int typeCode,
                      CharSequence value,
                      int locationId,
                      int properties)
            throws XPathException
Specified by:
attribute in interface Receiver

characters

public void characters(CharSequence chars,
                       int locationId,
                       int properties)
            throws XPathException
Notify a text node. Adjacent text nodes must have already been merged
Specified by:
characters in interface Receiver

close

public void close()
            throws XPathException
Callback interface for SAX: not for application use
Specified by:
close in interface Receiver
Overrides:
close in interface Builder

comment

public void comment(CharSequence chars,
                    int locationId,
                    int properties)
            throws XPathException
Notify a comment
Specified by:
comment in interface Receiver

endElement

public void endElement()
            throws XPathException
Notify the end of an element
Specified by:
endElement in interface Receiver

graftElement

public void graftElement(ElementImpl element)
            throws XPathException
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.
Parameters:
element - the element to be grafted in as a new child.

namespace

public void namespace(int namespaceCode,
                      int properties)
Specified by:
namespace in interface Receiver

open

public void open()
            throws XPathException
Callback interface for SAX: not for application use
Specified by:
open in interface Receiver
Overrides:
open in interface Builder

processingInstruction

public void processingInstruction(String name,
                                  CharSequence remainder,
                                  int locationId,
                                  int properties)
Notify a processing instruction
Specified by:
processingInstruction in interface Receiver

setNodeFactory

public void setNodeFactory(NodeFactory factory)
Set the Node Factory to use. If none is specified, the Builder uses its own.
Parameters:
factory - the node factory to be used. This allows custom objects to be used to represent the elements in the tree.

setUnparsedEntity

public void setUnparsedEntity(String name,
                              String uri,
                              String publicId)
Set an unparsed entity URI for the document
Specified by:
setUnparsedEntity in interface Receiver

startContent

public void startContent()
            throws XPathException
Specified by:
startContent in interface Receiver

startElement

public void startElement(int nameCode,
                         int typeCode,
                         int locationId,
                         int properties)
            throws XPathException
Notify the start of an element
Specified by:
startElement in interface Receiver