net.sf.saxon.tree

Class TreeBuilder

public class TreeBuilder extends Builder

The TreeBuilder class is responsible for taking a stream of Receiver events and constructing a Document tree using the linked tree implementation.

Author: Michael H. Kay

Constructor Summary
TreeBuilder()
create a Builder and initialise variables
Method Summary
voidattribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
voidcharacters(CharSequence chars, int locationId, int properties)
Notify a text node.
voidclose()
Close the stream of Receiver events
voidcomment(CharSequence chars, int locationId, int properties)
Notify a comment
voidendDocument()
Notify the end of the document
voidendElement()
Notify the end of an element
NodeInfogetCurrentRoot()
Get the current root node.
voidgraftElement(ElementImpl element)
graftElement() allows an element node to be transferred from one tree to another.
voidnamespace(int namespaceCode, int properties)
voidopen()
Open the stream of Receiver events
voidprocessingInstruction(String name, CharSequence remainder, int locationId, int properties)
Notify a processing instruction
voidreset()
voidsetAllocateSequenceNumbers(boolean allocate)
Set whether the builder should allocate sequence numbers to elements as they are added to the tree.
voidsetNodeFactory(NodeFactory factory)
Set the Node Factory to use.
voidsetUnparsedEntity(String name, String uri, String publicId)
Set an unparsed entity URI for the document
voidstartContent()
voidstartDocument(int properties)
Start of a document node.
voidstartElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element

Constructor Detail

TreeBuilder

public TreeBuilder()
create a Builder and initialise variables

Method Detail

attribute

public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)

characters

public void characters(CharSequence chars, int locationId, int properties)
Notify a text node. Adjacent text nodes must have already been merged

close

public void close()
Close the stream of Receiver events

comment

public void comment(CharSequence chars, int locationId, int properties)
Notify a comment

endDocument

public void endDocument()
Notify the end of the document

endElement

public void endElement()
Notify the end of an element

getCurrentRoot

public NodeInfo getCurrentRoot()
Get the current root node. This will normally be a document node, but if the root of the tree is an element node, it can be an element.

Returns: the root of the tree that is currently being built, or that has been most recently built using this builder

graftElement

public void graftElement(ElementImpl element)
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)

open

public void open()
Open the stream of Receiver events

processingInstruction

public void processingInstruction(String name, CharSequence remainder, int locationId, int properties)
Notify a processing instruction

reset

public void reset()

setAllocateSequenceNumbers

public void setAllocateSequenceNumbers(boolean allocate)
Set whether the builder should allocate sequence numbers to elements as they are added to the tree. This is normally done, because it provides a quick way of comparing document order. But nodes added using XQuery update are not sequence-numbered.

Parameters: allocate true if sequence numbers are to be allocated

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

startContent

public void startContent()

startDocument

public void startDocument(int properties)
Start of a document node. This event is ignored: we simply add the contained elements to the current document

startElement

public void startElement(int nameCode, int typeCode, int locationId, int properties)
Notify the start of an element