Package com.icl.saxon.om
Class Builder
java.lang.Object
com.icl.saxon.output.Emitter
com.icl.saxon.om.Builder
- All Implemented Interfaces:
Result
,SourceLocator
,ErrorHandler
,Locator
- Direct Known Subclasses:
TinyBuilder
,TreeBuilder
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
FieldsModifier and TypeFieldDescriptionprotected int
protected Controller
protected DocumentInfo
protected boolean
protected ErrorHandler
protected ErrorListener
protected Writer
protected int
protected boolean
protected boolean
protected int
protected boolean
protected PreviewManager
static final int
protected boolean
protected Stripper
protected boolean
static final int
Fields inherited from class com.icl.saxon.output.Emitter
locator, namePool, outputProperties, outputStream, systemId, writer
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuild the tree from an input source.void
Callback interface for SAX: not for application usevoid
Callback interface for SAX: not for application useint
Get the current documentint
Get the Stripper in useboolean
isTiming()
Get timing optionprotected void
reportError
(SAXParseException e, boolean isFatal) Common routine for errors and fatal errorsvoid
void
setDiscardCommentsAndPIs
(boolean discard) Indicate whether comments and Processing Instructions should be discardedvoid
Set the SAX error handler to use.void
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 handlervoid
setLineNumbering
(boolean onOrOff) Set line numbering on or offvoid
Set the PreviewManager to usevoid
setRootNode
(DocumentInfo doc) Set the root (document) node to use.void
Set the Stripper to usevoid
setTiming
(boolean on) Set timing option on or offabstract void
setUnparsedEntity
(String name, String uri) Set the URI for an unparsed entity in the document.void
Callback interface for SAX: not for application useMethods 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, setWriter, startDocument, startElement, usesWriter
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.Locator
getSystemId
Methods inherited from interface javax.xml.transform.SourceLocator
getSystemId
-
Field Details
-
STANDARD_TREE
public static final int STANDARD_TREE- See Also:
-
TINY_TREE
public static final int TINY_TREE- See Also:
-
estimatedLength
protected int estimatedLength -
errorOutput
-
stripper
-
previewManager
-
discardComments
protected boolean discardComments -
currentDocument
-
errorHandler
-
errorListener
-
failed
protected boolean failed -
started
protected boolean started -
timing
protected boolean timing -
inDTD
protected boolean inDTD -
lineNumbering
protected boolean lineNumbering -
lineNumber
protected int lineNumber -
columnNumber
protected int columnNumber -
controller
-
-
Constructor Details
-
Builder
public Builder()create a Builder and initialise variables
-
-
Method Details
-
setController
-
setRootNode
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. -
setTiming
public void setTiming(boolean on) Set timing option on or off -
isTiming
public boolean isTiming()Get timing option -
setLineNumbering
public void setLineNumbering(boolean onOrOff) Set line numbering on or off -
setStripper
Set the Stripper to use -
getStripper
Get the Stripper in use -
setPreviewManager
Set the PreviewManager to use -
setDiscardCommentsAndPIs
public void setDiscardCommentsAndPIs(boolean discard) Indicate whether comments and Processing Instructions should be discarded -
setErrorHandler
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
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
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
-
build
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.
- Throws:
TransformerException
- if the input document could not be read or if it was not parsed correctly.
-
getCurrentDocument
Get the current document- Returns:
- the document that has been most recently built using this builder
-
warning
Callback interface for SAX: not for application use- Specified by:
warning
in interfaceErrorHandler
-
error
Callback interface for SAX: not for application use- Specified by:
error
in interfaceErrorHandler
- Throws:
SAXException
-
fatalError
Callback interface for SAX: not for application use- Specified by:
fatalError
in interfaceErrorHandler
- Throws:
SAXException
-
reportError
Common routine for errors and fatal errors -
setUnparsedEntity
Set the URI for an unparsed entity in the document. Abstract method to be implemented in each subclass.- Overrides:
setUnparsedEntity
in classEmitter
-
getPublicId
- Specified by:
getPublicId
in interfaceLocator
- Specified by:
getPublicId
in interfaceSourceLocator
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumber
in interfaceLocator
- Specified by:
getLineNumber
in interfaceSourceLocator
-
getColumnNumber
public int getColumnNumber()- Specified by:
getColumnNumber
in interfaceLocator
- Specified by:
getColumnNumber
in interfaceSourceLocator
-