net.sf.saxon.event

Class Builder

public abstract class Builder extends Object implements Receiver

The abstract Builder class is responsible for taking a stream of SAX events and constructing a Document tree. There is one concrete subclass for each tree implementation.

Author: Michael H. Kay

Field Summary
protected StringbaseURI
protected Configurationconfig
protected NodeInfocurrentRoot
protected booleanlineNumbering
static intLINKED_TREE
Constant denoting the "linked tree" in which each node is represented as an object
protected NamePoolnamePool
protected PipelineConfigurationpipe
protected booleanstarted
protected StringsystemId
static intSTANDARD_TREE
Alternative constant denoting the "linked tree" in which each node is represented as an object Retained for backwards compatibility
protected booleantiming
static intTINY_TREE
Constant denoting the "tiny tree" in which the tree is represented internally using arrays of integers
static intTINY_TREE_CONDENSED
Constant denoting the "tiny tree condensed", a variant of the tiny tree in which text and attribute nodes sharing the same string value use shared storage for the value.
static intUNSPECIFIED_TREE_MODEL
Constant denoting a request for the default tree model
Constructor Summary
Builder()
Create a Builder and initialise variables
Method Summary
static NodeInfobuild(Source source, Stripper stripper, Configuration config)
Static method to build a document from any kind of Source object.
static NodeInfobuild(Source source, Stripper stripper, PipelineConfiguration pipe)
Static method to build a document from any kind of Source object.
voidclose()
StringgetBaseURI()
Get the base URI of the document node of the tree being constructed by this builder
ConfigurationgetConfiguration()
Get the Configuration
NodeInfogetCurrentRoot()
Get the current root node.
PipelineConfigurationgetPipelineConfiguration()
StringgetSystemId()
The SystemId is equivalent to the document-uri property defined in the XDM data model.
booleanisTiming()
Get timing option
voidopen()
voidreset()
Reset the builder to its initial state.
voidsetBaseURI(String baseURI)
Set the base URI of the document node of the tree being constructed by this builder
voidsetLineNumbering(boolean lineNumbering)
Set line numbering on or off
voidsetPipelineConfiguration(PipelineConfiguration pipe)
voidsetSystemId(String systemId)
The SystemId is equivalent to the document-uri property defined in the XDM data model.
voidsetTiming(boolean on)
Set timing option on or off
booleanusesTypeAnnotations()
Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute events

Field Detail

baseURI

protected String baseURI

config

protected Configuration config

currentRoot

protected NodeInfo currentRoot

lineNumbering

protected boolean lineNumbering

LINKED_TREE

public static final int LINKED_TREE
Constant denoting the "linked tree" in which each node is represented as an object

namePool

protected NamePool namePool

pipe

protected PipelineConfiguration pipe

started

protected boolean started

systemId

protected String systemId

STANDARD_TREE

public static final int STANDARD_TREE
Alternative constant denoting the "linked tree" in which each node is represented as an object Retained for backwards compatibility

timing

protected boolean timing

TINY_TREE

public static final int TINY_TREE
Constant denoting the "tiny tree" in which the tree is represented internally using arrays of integers

TINY_TREE_CONDENSED

public static final int TINY_TREE_CONDENSED
Constant denoting the "tiny tree condensed", a variant of the tiny tree in which text and attribute nodes sharing the same string value use shared storage for the value.

UNSPECIFIED_TREE_MODEL

public static final int UNSPECIFIED_TREE_MODEL
Constant denoting a request for the default tree model

Constructor Detail

Builder

public Builder()
Create a Builder and initialise variables

Method Detail

build

public static NodeInfo build(Source source, Stripper stripper, Configuration config)

Deprecated: since Saxon 9.2: use Configuration. The method was also changed in 9.2 to ignore the stripper parameter.

Static method to build a document from any kind of Source object. If the source is already in the form of a tree, it is wrapped as required.

The preferred way to construct a document tree from a Source object is to use the method Configuration.

Parameters: source Any javax.xml.transform.Source object stripper A stripper object, if whitespace text nodes are to be stripped; otherwise null. Ignored since Saxon 9.2 config The Configuration object

Returns: the NodeInfo of the start node in the resulting document object.

build

public static NodeInfo build(Source source, Stripper stripper, PipelineConfiguration pipe)

Deprecated: since Saxon 9.2: use Configuration. The method was also changed in 9.2 to ignore the stripper parameter.

Static method to build a document from any kind of Source object. If the source is already in the form of a tree, it is wrapped as required.

The preferred way to construct a document tree from a Source object is to use the method Configuration.

Parameters: source Any javax.xml.transform.Source object stripper A stripper object, if whitespace text nodes are to be stripped; otherwise null. Ignored since Saxon 9.2 pipe The PipelineConfiguration object

Returns: the NodeInfo of the start node in the resulting document object.

close

public void close()

getBaseURI

public String getBaseURI()
Get the base URI of the document node of the tree being constructed by this builder

Returns: the base URI

getConfiguration

public Configuration getConfiguration()
Get the Configuration

Returns: the Saxon configuration

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

getPipelineConfiguration

public PipelineConfiguration getPipelineConfiguration()

getSystemId

public String getSystemId()
The SystemId is equivalent to the document-uri property defined in the XDM data model. It should be set only in the case of a document that is potentially retrievable via this URI. This means the value will be null in the case of a temporary tree constructed in the course of executing a query or transformation.

Returns: the SystemId, that is, the document-uri.

isTiming

public boolean isTiming()
Get timing option

Returns: true if timing information has been requested

open

public void open()

reset

public void reset()
Reset the builder to its initial state. The most important effect of calling this method (implemented in subclasses) is to release any links to the constructed document tree, allowing the memory occupied by the tree to released by the garbage collector even if the Builder is still in memory. This can happen because the Builder is referenced from a parser in the Configuration's parser pool.

setBaseURI

public void setBaseURI(String baseURI)
Set the base URI of the document node of the tree being constructed by this builder

Parameters: baseURI the base URI

setLineNumbering

public void setLineNumbering(boolean lineNumbering)
Set line numbering on or off

Parameters: lineNumbering set to true if line numbers are to be maintained for nodes in the tree being constructed.

setPipelineConfiguration

public void setPipelineConfiguration(PipelineConfiguration pipe)

setSystemId

public void setSystemId(String systemId)
The SystemId is equivalent to the document-uri property defined in the XDM data model. It should be set only in the case of a document that is potentially retrievable via this URI. This means it should not be set in the case of a temporary tree constructed in the course of executing a query or transformation.

Parameters: systemId the SystemId, that is, the document-uri.

setTiming

public void setTiming(boolean on)
Set timing option on or off

Parameters: on set to true to turn timing on. This causes the builder to display statistical information about the tree that is constructed. It corresponds to the command line -t option

usesTypeAnnotations

public boolean usesTypeAnnotations()
Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute events

Returns: true if the Receiver makes any use of this information. If false, the caller may supply untyped nodes instead of supplying the type annotation