com.icl.saxon.om

Class Builder

Implemented Interfaces:
ErrorHandler, Locator, Result, SourceLocator
Known Direct Subclasses:
TinyBuilder, TreeBuilder

public abstract class Builder
extends Emitter
implements ErrorHandler, Locator, SourceLocator

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.

Nested Class Summary

Field Summary

static int
STANDARD_TREE
static int
TINY_TREE
protected int
columnNumber
protected Controller
controller
protected DocumentInfo
currentDocument
protected boolean
discardComments
protected ErrorHandler
errorHandler
protected ErrorListener
errorListener
protected Writer
errorOutput
protected int
estimatedLength
protected boolean
failed
protected boolean
inDTD
protected int
lineNumber
protected boolean
lineNumbering
protected PreviewManager
previewManager
protected boolean
started
protected Stripper
stripper
protected boolean
timing

Fields inherited from class com.icl.saxon.output.Emitter

locator, namePool, outputProperties, outputStream, systemId, writer

Constructor Summary

Builder()
create a Builder and initialise variables

Method Summary

DocumentInfo
build(SAXSource source)
Build the tree from an input source.
void
error(SAXParseException e)
Callback interface for SAX: not for application use
void
fatalError(SAXParseException e)
Callback interface for SAX: not for application use
int
getColumnNumber()
DocumentInfo
getCurrentDocument()
Get the current document
int
getLineNumber()
String
getPublicId()
Stripper
getStripper()
Get the Stripper in use
boolean
isTiming()
Get timing option
protected void
reportError(SAXParseException e, boolean isFatal)
Common routine for errors and fatal errors
void
setController(Controller c)
void
setDiscardCommentsAndPIs(boolean discard)
Indicate whether comments and Processing Instructions should be discarded
void
setErrorHandler(ErrorHandler eh)
Set the SAX error handler to use.
void
setErrorListener(ErrorListener eh)
Set the JAXP error listener to use, if no SAX errorHandler has been provided.
void
setErrorOutput(Writer writer)
Set output for error messages produced by the default error handler.
The default error handler does not throw an exception for parse errors or input I/O errors, rather it returns a result code and writes diagnostics to a user-specified output writer, which defaults to System.err
This call has no effect if setErrorHandler() has been called to supply a user-defined error handler
void
setLineNumbering(boolean onOrOff)
Set line numbering on or off
void
setPreviewManager(PreviewManager pm)
Set the PreviewManager to use
void
setRootNode(DocumentInfo doc)
Set the root (document) node to use.
void
setStripper(Stripper s)
Set the Stripper to use
void
setTiming(boolean on)
Set timing option on or off
void
setUnparsedEntity(String name, String uri)
Set the URI for an unparsed entity in the document.
void
warning(SAXParseException e)
Callback interface for SAX: not for application use

Methods inherited from class com.icl.saxon.output.Emitter

characters, comment, endDocument, endElement, getNamePool, getOutputProperties, getOutputStream, getSystemId, getWriter, makeEmitter, processingInstruction, setDocumentLocator, setEscaping, setNamePool, setOutputProperties, setOutputStream, setSystemId, setUnparsedEntity, setWriter, startDocument, startElement, usesWriter

Field Details

STANDARD_TREE

public static final int STANDARD_TREE

Field Value:
0


TINY_TREE

public static final int TINY_TREE

Field Value:
1


columnNumber

protected int columnNumber


controller

protected Controller controller


currentDocument

protected DocumentInfo currentDocument


discardComments

protected boolean discardComments


errorHandler

protected ErrorHandler errorHandler


errorListener

protected ErrorListener errorListener


errorOutput

protected Writer errorOutput


estimatedLength

protected int estimatedLength


failed

protected boolean failed


inDTD

protected boolean inDTD


lineNumber

protected int lineNumber


lineNumbering

protected boolean lineNumbering


previewManager

protected PreviewManager previewManager


started

protected boolean started


stripper

protected Stripper stripper


timing

protected boolean timing

Constructor Details

Builder

public Builder()
create a Builder and initialise variables

Method Details

build

public DocumentInfo build(SAXSource source)
            throws TransformerException
Build the tree from an input source. After building the tree, it can be walked as often as required using run(Document doc).

Parameters:
source - The source to use. SAXSource is a SAX-defined class that allows input from a URL, a byte stream, or a character stream. SAXON also provides a subclass, ExtendedInputSource, that allows input directly from a File.

Returns:
The DocumentInfo object that results from parsing the input.


error

public void error(SAXParseException e)
            throws SAXException
Callback interface for SAX: not for application use


fatalError

public void fatalError(SAXParseException e)
            throws SAXException
Callback interface for SAX: not for application use


getColumnNumber

public int getColumnNumber()


getCurrentDocument

public DocumentInfo getCurrentDocument()
Get the current document

Returns:
the document that has been most recently built using this builder


getLineNumber

public int getLineNumber()


getPublicId

public String getPublicId()


getStripper

public Stripper getStripper()
Get the Stripper in use


isTiming

public boolean isTiming()
Get timing option


reportError

protected void reportError(SAXParseException e,
                           boolean isFatal)
Common routine for errors and fatal errors


setController

public void setController(Controller c)


setDiscardCommentsAndPIs

public void setDiscardCommentsAndPIs(boolean discard)
Indicate whether comments and Processing Instructions should be discarded


setErrorHandler

public void setErrorHandler(ErrorHandler eh)
Set the SAX error handler to use. If none is specified, SAXON supplies its own, which writes error messages to the selected error output writer.

Parameters:
eh - The error handler to use. It must conform to the interface org.xml.sax.ErrorHandler


setErrorListener

public void setErrorListener(ErrorListener eh)
Set the JAXP error listener to use, if no SAX errorHandler has been provided.

Parameters:
eh - The error listener to use. It must conform to the interface javax.xml.transform.ErrorListener


setErrorOutput

public void setErrorOutput(Writer writer)
Set output for error messages produced by the default error handler.
The default error handler does not throw an exception for parse errors or input I/O errors, rather it returns a result code and writes diagnostics to a user-specified output writer, which defaults to System.err
This call has no effect if setErrorHandler() has been called to supply a user-defined error handler

Parameters:
writer - The Writer to use for error messages


setLineNumbering

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


setPreviewManager

public void setPreviewManager(PreviewManager pm)
Set the PreviewManager to use


setRootNode

public void setRootNode(DocumentInfo doc)
Set the root (document) node to use. This method is used to support the JAXP facility to attach transformation output to a supplied Document node. It must be called before startDocument(), and the type of document node must be compatible with the type of Builder used.


setStripper

public void setStripper(Stripper s)
Set the Stripper to use


setTiming

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


setUnparsedEntity

public void setUnparsedEntity(String name,
                              String uri)
Set the URI for an unparsed entity in the document. Abstract method to be implemented in each subclass.
Overrides:
setUnparsedEntity in interface Emitter


warning

public void warning(SAXParseException e)
Callback interface for SAX: not for application use