|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.xml.transform.Transformer | +--net.sf.saxon.Controller
Controller processes an XML file, calling registered node handlers when appropriate to process its elements, character content, and attributes. This is Saxon's implementation of the JAXP Transformer class
Constructor Summary | |
Controller(Configuration config)
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(int min,
int max,
ParameterSet params,
ParameterSet tunnelParams)
Apply a template imported from the stylesheet containing the current template. |
TailCall |
applyTemplates(SequenceIterator iterator,
Mode mode,
ParameterSet parameters,
ParameterSet tunnelParameters)
Process selected nodes using the handlers registered for a particular mode. |
void |
changeOutputDestination(java.util.Properties props,
javax.xml.transform.Result result,
boolean isFinal,
int validation,
SchemaType schemaType)
Set a new output destination, supplying the output format details. |
void |
changeToSequenceOutputDestination(SequenceReceiver out)
Set the output destination to write to a sequence. |
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. |
void |
defineGlobalParameters(Bindery bindery)
|
Bindery |
getBindery()
Get the current bindery. |
Configuration |
getConfiguration()
|
java.util.GregorianCalendar |
getCurrentDateTime()
Get the current date and time for this transformation. |
GroupIterator |
getCurrentGroupIterator()
Get the current group collection. |
Item |
getCurrentItem()
Get the current item. |
SequenceIterator |
getCurrentIterator()
Get the current iterator. |
Mode |
getCurrentMode()
Get the current mode. |
RegexIterator |
getCurrentRegexIterator()
Get the current regex iterator. |
Template |
getCurrentTemplate()
Get the current template. |
DecimalFormatManager |
getDecimalFormatManager()
Get the Decimal Format Manager. |
DocumentPool |
getDocumentPool()
Get the document pool. |
javax.xml.transform.ErrorListener |
getErrorListener()
Get the error listener. |
Executable |
getExecutable()
Get the Executable object. |
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. |
OutputURIResolver |
getOutputURIResolver()
Get the output URI resolver. |
java.lang.Object |
getParameter(java.lang.String expandedName)
Get a parameter to the transformation. |
javax.xml.transform.Result |
getPrincipalResult()
Get the principal result destination |
java.lang.String |
getPrincipalResultURI()
Get the URI of the principal result destination. |
DocumentInfo |
getPrincipalSourceDocument()
Get the principal source document. |
SequenceReceiver |
getReceiver()
Get the Receiver to which output is currently being written. |
int |
getRecoveryPolicy()
Get the policy for handling recoverable errors. |
int |
getRememberedNumber(NodeInfo node)
Get the number of a node if it is the last remembered one. |
RuleManager |
getRuleManager()
Get the Rule Manager. |
javax.xml.transform.URIResolver |
getStandardURIResolver()
Get the fallback URI resolver. |
TraceListener |
getTraceListener()
Get the TraceListener. |
javax.xml.transform.URIResolver |
getURIResolver()
Get the primary URI resolver. |
java.lang.Object |
getUserData(java.lang.Object node,
java.lang.String name)
Get user data associated with a node. |
boolean |
isTracing()
Test whether instruction execution is being traced. |
Builder |
makeBuilder()
Make a builder for the selected tree model. |
void |
makeContext(Item item)
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)
Make a Stripper configured to implement the whitespace stripping rules. |
XPathContext |
newXPathContext()
Make an XPathContext object for expression evaluation. |
void |
nextMatch(ParameterSet params,
ParameterSet tunnelParams)
Apply the next matching template. |
void |
pauseTracing(boolean pause)
Pause or resume tracing. |
NodeInfo |
prepareInputTree(javax.xml.transform.Source source)
Prepare an input tree for processing. |
javax.xml.transform.Result |
prepareNextStylesheet(java.lang.String href,
java.lang.String baseURI,
javax.xml.transform.Result result)
Prepare another stylesheet to handle the output of this one. |
void |
recoverableError(java.lang.String message,
javax.xml.transform.SourceLocator location)
Report a recoverable error. |
void |
recoverableError(javax.xml.transform.TransformerException err)
Report a recoverable error. |
void |
registerDocument(DocumentInfo doc,
java.lang.String systemId)
Add a document to the document pool. |
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 |
resetOutputDestination(SequenceReceiver receiver)
Close the current receiver, and revert to the previous receiver. |
void |
restoreContext(java.lang.Object[] x)
Restore the context. |
void |
run(NodeInfo node)
Process a Document. |
java.lang.Object[] |
saveContext()
Save the XSLT processing context. |
void |
setCurrentGroupIterator(GroupIterator collection)
Set the current group collection. |
void |
setCurrentIterator(SequenceIterator iterator)
Set a new current item sequence iterator. |
void |
setCurrentMode(Mode mode)
Set the current mode (for use by the built-in handlers). |
void |
setCurrentRegexIterator(RegexIterator currentRegexIterator)
Set the current regex iterator |
void |
setCurrentTemplate(Template template)
Set the current template. |
void |
setDecimalFormatManager(DecimalFormatManager manager)
Set the Decimal Format Manager. |
void |
setErrorListener(javax.xml.transform.ErrorListener listener)
Set the error listener. |
void |
setExecutable(Executable exec)
Associate this Controller with an Executable. |
void |
setGlobalContext()
Set the context to point to the root of the principal source document as the singleton focus Note: the caller is expected to save the previous context and reset it later. |
void |
setInitialMode(java.lang.String expandedModeName)
Set the initial mode for the transformation. |
void |
setInitialTemplate(java.lang.String expandedName)
Set the initial named template to be used as the entry point |
void |
setLineNumbering(boolean onOrOff)
Set line numbering (of the source document) on or off. |
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 |
setOutputURIResolver(OutputURIResolver resolver)
Set the URI resolver for secondary output documents. |
void |
setParameter(java.lang.String expandedName,
java.lang.Object value)
Set a parameter for the transformation. |
void |
setPreparedStyleSheet(PreparedStyleSheet sheet)
Associate this Controller with a compiled stylesheet. |
void |
setPrincipalSourceDocument(DocumentInfo doc)
Set the principal source document (used for evaluating global variables) |
void |
setReceiver(SequenceReceiver receiver)
Change the Receiver to which output is written |
void |
setRememberedNumber(NodeInfo node,
int number)
Set the last remembered node, for node numbering purposes. |
void |
setRuleManager(RuleManager r)
Set the RuleManager, used to manage template rules for each mode. |
void |
setTreeModel(int model)
Set the tree data model to use. |
void |
setURIResolver(javax.xml.transform.URIResolver resolver)
Set an object that will be used to resolve URIs used in document(), etc. |
void |
setUserData(java.lang.Object node,
java.lang.String name,
java.lang.Object data)
Set user data associated with a node (or any other object). |
void |
transform(javax.xml.transform.Source source,
javax.xml.transform.Result result)
Perform a transformation from a Source document to a Result document. |
void |
transformDocument(NodeInfo startNode,
javax.xml.transform.Result result)
Render a source XML document supplied as a tree. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Controller(Configuration config)
config
- The Configuration used by this ControllerMethod Detail |
public Configuration getConfiguration()
public void setInitialMode(java.lang.String expandedModeName)
expandedModeName
- the name of the initial mode. The mode is
supplied as an expanded QName, that is "localname" if there is no
namespace, or "{uri}localname" otherwisepublic void run(NodeInfo node) throws javax.xml.transform.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 net.sf.saxon.event.Builder.
node
- The node at which processing should start
javax.xml.transform.TransformerException
- if the transformation fails for any
reasonpublic DocumentInfo getPrincipalSourceDocument()
public TailCall applyTemplates(SequenceIterator iterator, Mode mode, ParameterSet parameters, ParameterSet tunnelParameters) throws javax.xml.transform.TransformerException
iterator
- an Iterator over the nodes to be processed, in the
correct (sorted) ordermode
- 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.
javax.xml.transform.TransformerException
- if any dynamic error occurspublic void applyImports(int min, int max, ParameterSet params, ParameterSet tunnelParams) throws javax.xml.transform.TransformerException
min
- the minimum import precedence of template rules to be
consideredmax
- the maximum import precedence of template rules to be
consideredparams
- parameters supplied to xsl:apply-importstunnelParams
- tunnel parameters supplied to xsl:apply-imports (directly
or indirectly)
javax.xml.transform.TransformerException
- if any dynamic error occurspublic void nextMatch(ParameterSet params, ParameterSet tunnelParams) throws javax.xml.transform.TransformerException
params
- parameters supplied to the xsl:next-match instructiontunnelParams
- tunnel parameters supplied to xsl:apply-imports (directly
or indirectly)
javax.xml.transform.TransformerException
public void setOutputProperties(java.util.Properties properties)
setOutputProperties
in class javax.xml.transform.Transformer
properties
- the output properties to be used for the
transformationpublic java.util.Properties getOutputProperties()
getOutputProperties
in class javax.xml.transform.Transformer
public void setOutputProperty(java.lang.String name, java.lang.String value)
setOutputProperty
in class javax.xml.transform.Transformer
name
- the name of the propertyvalue
- the value of the propertypublic java.lang.String getOutputProperty(java.lang.String name)
getOutputProperty
in class javax.xml.transform.Transformer
name
- the name of the requested property
SaxonOutputKeys
public java.lang.String getPrincipalResultURI()
public javax.xml.transform.Result getPrincipalResult()
public void changeOutputDestination(java.util.Properties props, javax.xml.transform.Result result, boolean isFinal, int validation, SchemaType schemaType) throws javax.xml.transform.TransformerException
props
- properties defining the output formatresult
- Details of the new output destinationisFinal
- true if the destination is a final result tree
(either the principal output or a secondary result tree); false if
it is a temporary tree, xsl:attribute, etc.
javax.xml.transform.TransformerException
- if any dynamic error occurs; and
specifically, if an attempt is made to switch to a final output
destination while writing a temporary tree or sequencepublic void changeToSequenceOutputDestination(SequenceReceiver out) throws javax.xml.transform.TransformerException
out
- The SequenceOutputter to be used
javax.xml.transform.TransformerException
- if any dynamic error occurspublic void changeToTextOutputDestination(java.lang.StringBuffer buffer)
buffer
- the StringBuffer in which the string value of the node
will be assembledpublic void setReceiver(SequenceReceiver receiver)
public SequenceReceiver getReceiver()
public void resetOutputDestination(SequenceReceiver receiver) throws javax.xml.transform.TransformerException
receiver
- The receiver to revert to
javax.xml.transform.TransformerException
- if any dynamic error occurspublic void setInitialTemplate(java.lang.String expandedName) throws javax.xml.transform.TransformerException
expandedName
- The expanded name of the template in {uri}local format
javax.xml.transform.TransformerException
- if there is no named template with this namepublic Emitter makeMessageEmitter() throws javax.xml.transform.TransformerException
javax.xml.transform.TransformerException
- if any dynamic error occurs; in
particular, if the registered MessageEmitter class is not an
Emitterpublic Emitter getMessageEmitter()
public int getRecoveryPolicy()
public void setErrorListener(javax.xml.transform.ErrorListener listener)
setErrorListener
in class javax.xml.transform.Transformer
listener
- the ErrorListener to be usedpublic javax.xml.transform.ErrorListener getErrorListener()
getErrorListener
in class javax.xml.transform.Transformer
public void recoverableError(java.lang.String message, javax.xml.transform.SourceLocator location) throws javax.xml.transform.TransformerException
message
- the error messagelocation
- the stylesheet location at which the error
occurred
javax.xml.transform.TransformerException
- if the error listener decides not to
recover from the errorpublic void recoverableError(javax.xml.transform.TransformerException err) throws javax.xml.transform.TransformerException
err
- An exception holding information about the error
javax.xml.transform.TransformerException
- if the error listener decides not to
recover from the errorpublic Executable getExecutable()
public DocumentPool getDocumentPool()
public void clearDocumentPool()
public void setLineNumbering(boolean onOrOff)
onOrOff
- true to switch line numbering on; false to switch it offpublic void makeContext(Item item)
item
- the item that is to become the context itempublic void setPrincipalSourceDocument(DocumentInfo doc)
public java.lang.Object[] saveContext()
public void restoreContext(java.lang.Object[] x)
x
- An array of objects holding the saved context from a previous
call of saveContext()public void setGlobalContext()
public Bindery getBindery()
public void setURIResolver(javax.xml.transform.URIResolver resolver)
setURIResolver
in class javax.xml.transform.Transformer
resolver
- An object that implements the URIResolver interface, or
null.public javax.xml.transform.URIResolver getURIResolver()
getURIResolver
in class javax.xml.transform.Transformer
public javax.xml.transform.URIResolver getStandardURIResolver()
public void setOutputURIResolver(OutputURIResolver resolver)
resolver
- An object that implements the OutputURIResolver
interface, or null.public OutputURIResolver getOutputURIResolver()
public KeyManager getKeyManager()
public NamePool getNamePool()
public void setTreeModel(int model)
model
- the required tree model: Builder.STANDARD_TREE or
Builder.TINY_TREEBuilder
public Builder makeBuilder()
public Stripper makeStripper(Builder b)
b
- the Builder to which the events filtered by this stripper are
to be sent. May be null if the stripper is not being used for filtering
into a Builder.
public void registerDocument(DocumentInfo doc, java.lang.String systemId)
doc
- the root node of the document to be addedsystemId
- thesystem ID of this documentpublic void setDecimalFormatManager(DecimalFormatManager manager)
manager
- the Decimal Format Manager. This object is responsible
for maintaining all named and unnamed decimal format declarationspublic DecimalFormatManager getDecimalFormatManager()
public void setRuleManager(RuleManager r)
r
- the Rule Managerpublic RuleManager getRuleManager()
public TraceListener getTraceListener()
public final boolean isTracing()
public final void pauseTracing(boolean pause)
pause
- true if tracing is to pause; false if it is to resumepublic void addTraceListener(TraceListener trace)
trace
- the trace listener.public void removeTraceListener(TraceListener trace)
trace
- the trace listener.public void setPreparedStyleSheet(PreparedStyleSheet sheet)
sheet
- the compiled stylesheetpublic void setExecutable(Executable exec)
public void defineGlobalParameters(Bindery bindery)
public java.lang.Object getUserData(java.lang.Object node, java.lang.String name)
node
- the node to which the data is attachedname
- the name of the required property
public void setUserData(java.lang.Object node, java.lang.String name, java.lang.Object data)
node
- name
- data
- public void transform(javax.xml.transform.Source source, javax.xml.transform.Result result) throws javax.xml.transform.TransformerException
transform
in class javax.xml.transform.Transformer
source
- The input for the source tree. May be null if and only if an
initial template has been supplied.result
- The destination for the result tree.
javax.xml.transform.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 NodeInfo prepareInputTree(javax.xml.transform.Source source)
source
- the input tree. Must be either a DOMSource or a NodeInfo
public void transformDocument(NodeInfo startNode, javax.xml.transform.Result result) throws javax.xml.transform.TransformerException
startNode
- A Node that identifies the source document to be
transformed and the node where the transformation should start.
May be null if the transformation is to start using an initial template.result
- The output destination
javax.xml.transform.TransformerException
- if any dynamic error occurspublic javax.xml.transform.Result prepareNextStylesheet(java.lang.String href, java.lang.String baseURI, javax.xml.transform.Result result) throws javax.xml.transform.TransformerException
href
- URI of the next stylesheet to be appliedbaseURI
- base URI for resolving href if it's a relative
URIresult
- the output destination of the current stylesheet
javax.xml.transform.TransformerException
- if any dynamic error occurspublic void setParameter(java.lang.String expandedName, java.lang.Object value)
setParameter
in class javax.xml.transform.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 clearParameters()
clearParameters
in class javax.xml.transform.Transformer
public java.lang.Object getParameter(java.lang.String expandedName)
getParameter
in class javax.xml.transform.Transformer
expandedName
- the name of the required parameter, in
"{uri}local-name" format
public java.util.GregorianCalendar getCurrentDateTime()
public void setCurrentMode(Mode mode)
mode
- the new current modepublic Mode getCurrentMode()
public void setCurrentIterator(SequenceIterator iterator)
iterator
- The current sequence iterator. May be null, which
causes the context item, position, and size to be unset.public SequenceIterator getCurrentIterator()
public Item getCurrentItem() throws XPathException
XPathException
- if any dynamic error occurs, for example, if
there is no current itempublic void setCurrentTemplate(Template template)
template
- the current templatepublic Template getCurrentTemplate()
public void setCurrentGroupIterator(GroupIterator collection)
collection
- the new current GroupIteratorpublic GroupIterator getCurrentGroupIterator()
public void setCurrentRegexIterator(RegexIterator currentRegexIterator)
currentRegexIterator
- the current regex iteratorpublic RegexIterator getCurrentRegexIterator()
public XPathContext newXPathContext()
public void setRememberedNumber(NodeInfo node, int number)
node
- the node in questionnumber
- the number of this nodepublic int getRememberedNumber(NodeInfo node)
node
- the node for which remembered information is required
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |