|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.xml.transform.Transformer com.icl.saxon.Controller
Controller processes an XML file, calling registered node handlers when appropriate to process its elements, character content, and attributes.
Field Summary | |
static int |
DO_NOT_RECOVER
|
static int |
RECOVER_SILENTLY
|
static int |
RECOVER_WITH_WARNINGS
|
Constructor Summary | |
|
Controller()
Default constructor is provided for Java-only programs, i.e. |
protected |
Controller(TransformerFactoryImpl factory)
Create a Controller and initialise variables. |
Method Summary | |
void |
addTraceListener(TraceListener trace)
Adds the specified trace listener to receive trace events from this instance. |
void |
applyImports(Context c,
Mode mode,
int min,
int max,
ParameterSet params)
Apply a template imported from the stylesheet containing the current template |
void |
applyTemplates(Context c,
Expression select,
Mode mode,
ParameterSet parameters)
ApplyTemplates to process selected nodes using the handlers registered for a particular mode. |
void |
changeOutputDestination(java.util.Properties props,
Result result)
Set a new output destination, supplying the output format details. |
void |
changeToTextOutputDestination(java.lang.StringBuffer buffer)
Set a simple StringBuffer output destination. |
void |
clearDocumentPool()
Clear the document pool. |
void |
clearParameters()
Reset the parameters to a null list. |
int |
compare(NodeInfo n1,
NodeInfo n2)
Compare the position of two nodes in document order |
void |
disableWhitespaceStripping(boolean disable)
Disable whitespace stripping |
Bindery |
getBindery()
Get the current bindery |
DecimalFormatManager |
getDecimalFormatManager()
|
DocumentPool |
getDocumentPool()
Get the document pool. |
ErrorListener |
getErrorListener()
Get the error listener |
KeyManager |
getKeyManager()
Get the KeyManager |
Emitter |
getMessageEmitter()
Get the Emitter used for xsl:message output |
NamePool |
getNamePool()
Get the name pool in use |
java.util.Properties |
getOutputProperties()
Get the output properties for the transformation. |
java.lang.String |
getOutputProperty(java.lang.String name)
Get the value of an output property |
Outputter |
getOutputter()
Get the current outputter |
java.lang.Object |
getParameter(java.lang.String expandedName)
Get a parameter to the transformation |
int |
getRecoveryPolicy()
Get the policy for handling recoverable errors |
RuleManager |
getRuleManager()
|
URIResolver |
getStandardURIResolver()
Get the fallback URI resolver. |
TraceListener |
getTraceListener()
|
TransformerFactoryImpl |
getTransformerFactory()
|
int |
getTreeModel()
Get the tree model in use |
URIResolver |
getURIResolver()
Get the primary URI resolver. |
java.lang.Object |
getUserData(NodeInfo node,
java.lang.String name)
Get the named user data property for the node |
boolean |
isLineNumbering()
Determine whether line numbering is enabled |
boolean |
isTracing()
|
boolean |
isWhitespaceStrippingDisabled()
Determine if whitespace stripping is disabled |
Builder |
makeBuilder()
Make a builder for the selected tree model |
Context |
makeContext(NodeInfo node)
Create a new context with a given node as the current node and the only node in the current node list. |
Emitter |
makeMessageEmitter()
Make an Emitter to be used for xsl:message output |
Stripper |
makeStripper(Builder b)
|
void |
pauseTracing(boolean pause)
|
void |
removeTraceListener(TraceListener trace)
Removes the specified trace listener so that the next invocation of the render method will not send trace events to the listener. |
void |
reportRecoverableError(java.lang.String message,
SourceLocator location)
Report a recoverable error |
void |
reportRecoverableError(TransformerException err)
Report a recoverable error |
void |
reset()
Reset this Transformer to its original configuration. |
void |
resetOutputDestination(Outputter outputter)
Close the current outputter, and revert to the previous outputter. |
void |
run(NodeInfo node)
Process a Document. |
void |
setDecimalFormatManager(DecimalFormatManager manager)
|
void |
setDiagnosticName(java.lang.String name)
Set a diagnostic name for this transformation (accessible through toString()) |
void |
setErrorListener(ErrorListener listener)
Set the error listener |
void |
setLineNumbering(boolean onOrOff)
Set line numbering (of the source document) on or off |
void |
setMessageEmitter(Emitter emitter)
Set the Emitter to be used for xsl:message output |
void |
setNamePool(NamePool pool)
Set the name pool to be used |
void |
setOutputProperties(java.util.Properties properties)
Set the output properties for the transformation. |
void |
setOutputProperty(java.lang.String name,
java.lang.String value)
Set an output property for the transformation. |
void |
setParameter(java.lang.String expandedName,
java.lang.Object value)
Set a parameter for the transformation. |
void |
setParams(ParameterSet params)
Set parameters supplied externally (typically, on the command line). |
void |
setPreparedStyleSheet(PreparedStyleSheet sheet)
Associate this Controller with a compiled stylesheet |
void |
setRecoveryPolicy(int policy)
Set the policy for handling recoverable errors |
void |
setRuleManager(RuleManager r)
|
void |
setTraceListener(TraceListener trace)
|
void |
setTreeModel(int model)
Set the tree data model to use |
void |
setURIResolver(URIResolver resolver)
Set an object that will be used to resolve URIs used in document(), etc. |
void |
setUserData(NodeInfo node,
java.lang.String name,
java.lang.Object data)
Set a user data property for a node. |
java.lang.String |
toString()
|
void |
transform(Source source,
Result result)
Process the source tree to SAX parse events. |
void |
transformDocument(NodeInfo startNode,
Result result)
Render a source XML document supplied as a tree. |
protected boolean |
usesPreviewMode()
Does this transformation use preview mode? |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int RECOVER_SILENTLY
public static final int RECOVER_WITH_WARNINGS
public static final int DO_NOT_RECOVER
Constructor Detail |
public Controller()
protected Controller(TransformerFactoryImpl factory)
Method Detail |
public void reset()
Reset this Transformer
to its original configuration.
Transformer
is reset to the same state as when it was created with
TransformerFactory.newTransformer()
,
TransformerFactory.newTransformer(javax.xml.transform.Source source)
or
Templates.newTransformer()
.
reset()
is designed to allow the reuse of existing Transformer
s
thus saving resources associated with the creation of new Transformer
s.
The reset Transformer
is not guaranteed to have the same URIResolver
or ErrorListener
Object
s, e.g. Object.equals(Object obj)
.
It is guaranteed to have a functionally equal URIResolver
and ErrorListener
.
NOTE: the Saxon implementation of this method does not clear the document pool. This is because the
reason for resetting an existing Transformer rather than creating a new one is to reuse resources, and
the document pool is the most important resource held by the Transformer. If there is a requirement to
clear the document pool, then it is possible either (a) to call the clearDocumentPool()
method,
or (b) to create a new Transformer.
reset
in class Transformer
public TransformerFactoryImpl getTransformerFactory()
public void setDiagnosticName(java.lang.String name)
public java.lang.String toString()
public void run(NodeInfo node) throws TransformerException
This method is intended for use when performing a pure Java transformation, without a stylesheet. Where there is an XSLT stylesheet, use transformDocument() or transform() instead: those methods set up information from the stylesheet before calling run().
The process starts by calling the registered node handler to process the supplied node. Note that the same document can be processed any number of times, typically with different node handlers for each pass. The NodeInfo will typically be the root of a tree built using com.icl.saxon.om.Builder.
TransformerException
public void applyTemplates(Context c, Expression select, Mode mode, ParameterSet parameters) throws TransformerException
select
- A node-set expression (or more accurately a node-list)
that determines which nodes are selected.
Note: if the nodes are to be sorted, the select Expression will take care of this.mode
- Identifies the processing mode. It should match the mode defined when the
element handler was registered using setHandler with a mode parameter. Set this parameter to
null to invoke the default mode.parameters
- A ParameterSet containing the parameters to the handler/template being invoked.
Specify null if there are no parameters.
TransformerException
public void applyImports(Context c, Mode mode, int min, int max, ParameterSet params) throws TransformerException
TransformerException
public int compare(NodeInfo n1, NodeInfo n2)
compare
in interface NodeOrderComparer
n1
- The first noden2
- The second node
public void setOutputProperties(java.util.Properties properties)
setOutputProperties
in class Transformer
properties
- A set of output properties that will be
used to override any of the same properties in affect
for the transformation.OutputKeys
,
Properties
public java.util.Properties getOutputProperties()
getOutputProperties
in class Transformer
OutputKeys
,
Properties
,
XSL Transformations (XSLT) Version 1.0public void setOutputProperty(java.lang.String name, java.lang.String value)
setOutputProperty
in class Transformer
name
- A non-null String that specifies an output
property name, which may be namespace qualified.value
- The non-null string value of the output property.OutputKeys
public java.lang.String getOutputProperty(java.lang.String name)
getOutputProperty
in class Transformer
name
- A non-null String that specifies an output
property name, which may be namespace qualified.
OutputKeys
public void changeOutputDestination(java.util.Properties props, Result result) throws TransformerException
props
- Details of the new output formatresult
- Details of the new output destination
TransformerException
public void changeToTextOutputDestination(java.lang.StringBuffer buffer)
public Outputter getOutputter()
public void resetOutputDestination(Outputter outputter) throws TransformerException
outputter
- The outputter to revert to
TransformerException
public Emitter makeMessageEmitter() throws TransformerException
TransformerException
public void setMessageEmitter(Emitter emitter)
public Emitter getMessageEmitter()
public void setRecoveryPolicy(int policy)
public int getRecoveryPolicy()
public void setErrorListener(ErrorListener listener)
setErrorListener
in class Transformer
listener
- The new error listener.public ErrorListener getErrorListener()
getErrorListener
in class Transformer
public void reportRecoverableError(java.lang.String message, SourceLocator location) throws TransformerException
TransformerException
- if the error listener decides not to recover
from the errorpublic void reportRecoverableError(TransformerException err) throws TransformerException
TransformerException
- if the error listener decides not to recover
from the errorpublic DocumentPool getDocumentPool()
public void clearDocumentPool()
public void setLineNumbering(boolean onOrOff)
public boolean isLineNumbering()
public Context makeContext(NodeInfo node)
public Bindery getBindery()
public URIResolver getURIResolver()
getURIResolver
in class Transformer
public URIResolver getStandardURIResolver()
public KeyManager getKeyManager()
public void setNamePool(NamePool pool)
public NamePool getNamePool()
public void setTreeModel(int model)
public int getTreeModel()
public void disableWhitespaceStripping(boolean disable)
public boolean isWhitespaceStrippingDisabled()
public Builder makeBuilder()
public Stripper makeStripper(Builder b)
public void setDecimalFormatManager(DecimalFormatManager manager)
public DecimalFormatManager getDecimalFormatManager()
public void setRuleManager(RuleManager r)
public RuleManager getRuleManager()
public void setTraceListener(TraceListener trace)
public TraceListener getTraceListener()
public final boolean isTracing()
public void pauseTracing(boolean pause)
public void setPreparedStyleSheet(PreparedStyleSheet sheet)
protected boolean usesPreviewMode()
public void addTraceListener(TraceListener trace)
trace
- the trace listener.public void removeTraceListener(TraceListener trace)
trace
- the trace listener.public java.lang.Object getUserData(NodeInfo node, java.lang.String name)
name
- the name of the user data property to return
public void setUserData(NodeInfo node, java.lang.String name, java.lang.Object data)
name
- The name of the user data property to be set. Any existing user data property
of the same name will be overwritten.data
- an object to be saved with this element, which can be
retrieved later using getUserData().public void transform(Source source, Result result) throws TransformerException
transform
in class Transformer
source
- The input for the source tree.result
- The destination for the result tree.
TransformerException
- if the transformation fails. As a special case,
the method throws a TerminationException (a subclass of TransformerException)
if the transformation was terminated using xsl:message terminate="yes".public void transformDocument(NodeInfo startNode, Result result) throws TransformerException
startNode
- A Node that identifies the source document to be transformed and the
node where the transformation should startresult
- The output destination
TransformerException
public void setParameter(java.lang.String expandedName, java.lang.Object value)
setParameter
in class Transformer
expandedName
- The name of the parameter in {uri}local formatvalue
- The value object. This can be any valid Java object
it follows the same conversion rules as a value returned from a Saxon extension function.public void setParams(ParameterSet params)
params
- A ParameterSet containing the (name, value) pairs.public void clearParameters()
clearParameters
in class Transformer
public java.lang.Object getParameter(java.lang.String expandedName)
getParameter
in class Transformer
expandedName
- of Object
to get
public void setURIResolver(URIResolver resolver)
setURIResolver
in class Transformer
resolver
- An object that implements the URIResolver interface,
or null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |