public class Controller extends java.lang.Object implements ContextOriginator
The Controller is serially reusable: when one transformation or query is finished, it can be used to run another. However, there is no advantage in doing this rather than allocating a new Controller each time.
A dummy Controller is created when running free-standing XPath expressions.
The Controller holds those parts of the dynamic context that do not vary during the course of a transformation or query, or that do not change once their value has been computed. This also includes those parts of the static context that are required at run-time.
Many methods on the Controller are designed for internal use and should not be considered stable. From release 8.4 onwards, those methods that are considered sufficiently stable to constitute path of the Saxon public API are labelled with the JavaDoc tag "since": the value indicates the release at which the method was added to the public API.
Prior to Saxon 9.6 the Controller implemented (extended) the JAXP Transformer
interface, and advanced applications were able to down-cast the Transformer to a Controller.
This is no longer the case. Instead, the JAXP factory delivers an instance of TransformerImpl
,
from which the Controller is accessible if required. Because the Controller is no longer required
to implement the JAXP interface, it has been possible to make it less monolithic, so some of the
things it did are now done elsewhere: for example, it no longer handles global parameters
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANONYMOUS_PRINCIPAL_OUTPUT_URI |
Constructor and Description |
---|
Controller(Configuration config)
Create a Controller and initialise variables.
|
Controller(Configuration config,
Executable executable)
Create a Controller and initialise variables.
|
Modifier and Type | Method and Description |
---|---|
void |
addTraceListener(TraceListener trace)
Adds the specified trace listener to receive trace events from
this instance.
|
void |
addUnavailableOutputDestination(DocumentURI uri)
Add a URI to the set of output destinations that cannot be written to, either because
they have already been written to, or because they have been read
|
SequenceOutputter |
allocateSequenceOutputter(int size)
Allocate a SequenceOutputter for a new output destination.
|
void |
applyTemplates(Sequence source,
Receiver outputDestination)
Perform a transformation from a Source document to a Result document.
|
void |
callTemplate(StructuredQName initialTemplateName,
Receiver outputDestination)
Transform a source XML document supplied as a tree.
|
void |
checkImplicitResultTree()
Check whether an XSLT implicit result tree can be written.
|
boolean |
checkUniqueOutputDestination(DocumentURI uri)
Check that an output destination has not been used before, optionally adding
this URI to the set of URIs that have been used.
|
void |
clearDocumentPool()
Clear the document pool.
|
AccumulatorManager |
getAccumulatorManager()
Get the accumulator manager for this transformation.
|
java.util.Stack<AttributeSet> |
getAttributeSetEvaluationStack()
Get the stack of attribute sets being evaluated (for detection of cycles)
|
java.lang.String |
getBaseOutputURI()
Get the base output URI.
|
Bindery |
getBindery(PackageData packageData)
Get the bindery for the global variables in a particular package.
|
CollectionFinder |
getCollectionFinder()
Get the collection finder associated with this configuration.
|
CollectionURIResolver |
getCollectionURIResolver()
Deprecated.
since 9.7. Use
getCollectionFinder() |
Configuration |
getConfiguration()
Get the Configuration associated with this Controller.
|
Sequence |
getConvertedParameter(StructuredQName name,
SequenceType requiredType,
XPathContext context)
Get the value of a parameter, converted and/or type-checked
|
java.lang.String |
getCookedBaseOutputURI()
Get the base output URI after processing.
|
DateTimeValue |
getCurrentDateTime()
Get the current date and time for this query or transformation.
|
java.lang.String |
getDefaultCollection()
Get the name of the default collection.
|
DocumentPool |
getDocumentPool()
Get the document pool.
|
UnfailingErrorListener |
getErrorListener()
Get the error listener.
|
Executable |
getExecutable()
Get the Executable object.
|
Item |
getGlobalContextItem()
Get the item used as the context for evaluating global variables.
|
int |
getImplicitTimezone()
Get the implicit timezone for this query or transformation
|
Mode |
getInitialMode()
Get the initial mode for the transformation
|
StructuredQName |
getInitialModeName()
Get the name of the initial mode for the transformation
|
StructuredQName |
getInitialTemplate()
Get the initial template
|
java.util.Map<StructuredQName,Sequence> |
getInitialTemplateParameters(boolean tunnel)
Get the parameters for the initial template
|
KeyManager |
getKeyManager()
Get the KeyManager.
|
java.util.Map<StructuredQName,java.lang.Integer> |
getMessageCounters()
Get the message counters
|
Receiver |
getMessageEmitter()
Get the Receiver used for xsl:message output.
|
TreeModel |
getModel()
Get the tree model that will be used.
|
OutputURIResolver |
getOutputURIResolver()
Get the output URI resolver.
|
Sequence |
getParameter(StructuredQName name)
Get the value of a supplied parameter (XSLT) or external variable (XQuery)
|
PathMap |
getPathMapForDocumentProjection()
Get the path map used for document projection, if any.
|
Receiver |
getPrincipalResult()
Get the principal result destination.
|
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.
|
int |
getSchemaValidationMode()
Ask whether source documents loaded using the doc(), document(), and collection()
functions, or supplied as a StreamSource or SAXSource to the transform() or addParameter() method
should be subjected to schema validation
|
SpaceStrippingRule |
getSpaceStrippingRule()
Return the default whitespace-stripping rules that apply to this transformation or query.
|
javax.xml.transform.URIResolver |
getStandardURIResolver()
Get the fallback URI resolver.
|
Receiver |
getStreamingReceiver(Mode mode,
Receiver result)
Get a receiver to which the input to this transformation can be supplied
as a stream of events, causing the transformation to be executed in streaming mode.
|
StylesheetCache |
getStylesheetCache()
Get the cache of stylesheets (cached during calls on fn:transform()) for this query or transformation.
|
Logger |
getTraceFunctionDestination()
Get the destination for output from the fn:trace() function.
|
TraceListener |
getTraceListener()
Get the TraceListener.
|
UnparsedTextURIResolver |
getUnparsedTextURIResolver()
Get the URI resolver for the unparsed-text() function.
|
javax.xml.transform.URIResolver |
getURIResolver()
Get the URI resolver.
|
java.lang.Object |
getUserData(java.lang.Object key,
java.lang.String name)
Get user data associated with a key.
|
boolean |
hasThereBeenAnExplicitResultDocument()
Test whether an explicit result tree has been written using xsl:result-document
|
void |
incrementMessageCounter(StructuredQName code)
Increment a counter in the message counters.
|
void |
initializeController(GlobalParameterSet params)
Initialize the controller ready for a new transformation.
|
boolean |
isAssertionsEnabled()
Ask whether assertions (xsl:assert instructions) have been enabled at run time.
|
boolean |
isBuildTree()
Ask whether the principal transformation results should generate a result tree, or should be returned in raw sequence form
|
boolean |
isStripSourceTree()
Ask whether the transformation will perform whitespace stripping for supplied source trees as defined
by the xsl:strip-space and xsl:preserve-space declarations in the stylesheet.
|
boolean |
isStylesheetStrippingTypeAnnotations()
Ask whether the executable is a stylesheet whose top-level package
contains requests stripping of type annotations
|
boolean |
isTracing()
Test whether instruction execution is being traced.
|
boolean |
isUnusedOutputDestination(DocumentURI uri)
Determine whether an output URI is available for use.
|
Builder |
makeBuilder()
Make a builder for the selected tree model.
|
PipelineConfiguration |
makePipelineConfiguration()
Make a PipelineConfiguration based on the properties of this Controller.
|
NodeInfo |
makeSourceTree(javax.xml.transform.Source source,
boolean close,
int validationMode)
Make a source tree from a source supplied as a StreamSource or SAXSource
|
Stripper |
makeStripper(Receiver next)
Make a Stripper configured to implement the whitespace stripping rules.
|
XPathContextMajor |
newXPathContext()
Make an XPathContext object for expression evaluation.
|
void |
pauseTracing(boolean pause)
Pause or resume tracing.
|
void |
preEvaluateGlobals(XPathContext context)
Pre-evaluate global variables (when debugging/tracing).
|
NodeInfo |
prepareInputTree(javax.xml.transform.Source source)
Prepare an input tree for processing.
|
void |
recoverableError(XPathException err)
Report a recoverable error.
|
void |
registerDocument(TreeInfo doc,
DocumentURI uri)
Add a document to the document pool, and check that it is suitable for use in this query or
transformation.
|
void |
registerGlobalVariableDependency(GlobalVariable one,
GlobalVariable two)
Register the dependency of one variable ("one") upon another ("two"), throwing an exception if this would establish
a cycle of dependencies.
|
void |
releaseAttributeSetEvaluationStack() |
void |
removeTraceListener(TraceListener trace)
Removes the specified trace listener so that the listener will no longer
receive trace events.
|
void |
removeUnavailableOutputDestination(DocumentURI uri)
Remove a URI from the set of output destinations that cannot be written to or read from.
|
void |
reportFatalError(XPathException err)
Report a fatal error
|
void |
reset()
Reset this
Transformer to its original configuration. |
void |
reuseSequenceOutputter(SequenceOutputter out)
Accept a SequenceOutputter that is now available for reuse
|
void |
setApplyFunctionConversionRulesToExternalVariables(boolean applyConversionRules) |
void |
setAssertionsEnabled(boolean enabled)
Ask whether assertions (xsl:assert instructions) have been enabled at run time.
|
void |
setBaseOutputURI(java.lang.String uri)
Set the base output URI.
|
void |
setBuildTree(boolean build)
Say whether the principal transformation results should generate a result tree, or should be returned in raw sequence form
|
void |
setCollectionFinder(CollectionFinder cf)
Set the collection finder associated with this configuration.
|
void |
setCollectionURIResolver(CollectionURIResolver resolver)
Deprecated.
since 9.7. Use
setCollectionFinder(CollectionFinder) |
void |
setCurrentDateTime(DateTimeValue dateTime)
Set the current date and time for this query or transformation.
|
void |
setDefaultCollection(java.lang.String uri)
Set the name of the default collection.
|
void |
setErrorListener(javax.xml.transform.ErrorListener listener)
Set the error listener.
|
void |
setGlobalContextItem(Item contextItem)
Set the item used as the context for evaluating global variables.
|
void |
setGlobalContextItem(Item contextItem,
boolean alreadyStripped)
Set the item used as the context for evaluating global variables.
|
void |
setInitialMode(StructuredQName expandedModeName)
Set the initial mode for the transformation.
|
void |
setInitialTemplate(StructuredQName qName)
Set the initial named template to be used as the entry point, when the transformation is invoked
via the
transform(Source, Receiver) method. |
void |
setInitialTemplateParameters(java.util.Map<StructuredQName,Sequence> params,
boolean tunnel)
Set parameters for the initial template (whether this is a named template, or a template
rule invoked to process the initial input item)
|
void |
setMessageEmitter(Receiver receiver)
Set the Receiver to be used for xsl:message output.
|
void |
setMessageReceiverClassName(java.lang.String name)
Set the message receiver class name
|
void |
setModel(TreeModel model)
Set the tree model to use.
|
void |
setOutputURIResolver(OutputURIResolver resolver)
Set the URI resolver for secondary output documents.
|
void |
setRecoveryPolicy(int policy)
Set the policy for handling recoverable XSLT errors.
|
void |
setRememberedNumber(NodeInfo node,
int number)
Set the last remembered node, for node numbering purposes.
|
void |
setSchemaValidationMode(int validationMode)
Say whether source documents loaded using the doc(), document(), and collection()
functions, or supplied as a StreamSource or SAXSource to the transform() or addParameter() method,
should be subjected to schema validation.
|
void |
setStripSourceTrees(boolean strip)
Say whether the transformation should perform whitespace stripping as defined
by the xsl:strip-space and xsl:preserve-space declarations in the stylesheet
in the case where a source tree is supplied to the transformation as a tree
(typically a DOMSource, or a Saxon NodeInfo).
|
void |
setThereHasBeenAnExplicitResultDocument()
Set that an explicit result tree has been written using xsl:result-document
|
void |
setTraceFunctionDestination(Logger stream)
Set the destination for output from the fn:trace() function.
|
void |
setTraceListener(TraceListener listener)
Set a TraceListener, replacing any existing TraceListener
|
void |
setUnparsedTextURIResolver(UnparsedTextURIResolver resolver)
Set an UnparsedTextURIResolver to be used to resolve URIs passed to the XSLT
unparsed-text() function.
|
void |
setURIResolver(javax.xml.transform.URIResolver resolver)
Set an object that will be used to resolve URIs used in
document(), etc.
|
void |
setUseDocumentProjection(PathMap pathMap)
Indicate whether document projection should be used, and supply the PathMap used to control it.
|
void |
setUserData(java.lang.Object key,
java.lang.String name,
java.lang.Object data)
Set user data associated with a key.
|
void |
transform(javax.xml.transform.Source source,
Receiver receiver)
Perform a transformation from a Source document to a Result document.
|
void |
transformDocument(NodeInfo startNode,
Receiver outputDestination)
Transform a source XML document supplied as a tree.
|
void |
warning(java.lang.String message,
java.lang.String errorCode,
Location locator)
Report a run-time warning
|
public static final java.lang.String ANONYMOUS_PRINCIPAL_OUTPUT_URI
public Controller(Configuration config)
config
- The Configuration used by this Controllerpublic Controller(Configuration config, Executable executable)
config
- The Configuration used by this Controllerexecutable
- The executable used by this Controllerpublic 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 above is from the JAXP specification. With Saxon, it's unlikely that reusing a Transformer will
give any performance benefits over creating a new one. The one case where it might be beneficial is
to reuse the document pool (the set of documents that have been loaded using the doc() or document()
functions). Therefore, this method does not clear the document pool. If you want to clear the document
pool, call the method clearDocumentPool()
as well.
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
.
public Configuration getConfiguration()
public void setInitialMode(StructuredQName expandedModeName) throws XPathException
XSLT 2.0 allows a transformation to be started in a mode other than the default mode. The transformation then starts by looking for the template rule in this mode that best matches the initial context node.
This method may eventually be superseded by a standard JAXP method.
expandedModeName
- the name of the initial mode. The mode is
supplied as an expanded QName. Two special values are recognized, in the
reserved XSLT namespace:
xsl:unnamed to indicate the mode with no name, and xsl:default to indicate the
mode defined in the stylesheet header as the default mode.
The value null also indicates the unnamed mode.XPathException
- if the requested mode is not defined in the stylesheetpublic StructuredQName getInitialModeName()
public Mode getInitialMode()
public AccumulatorManager getAccumulatorManager()
public Sequence getParameter(StructuredQName name)
name
- the QName of the parameterpublic Sequence getConvertedParameter(StructuredQName name, SequenceType requiredType, XPathContext context) throws XPathException
name
- the name of the stylesheet parameter (XSLT) or external variable (XQuery)requiredType
- the declared type of the parametercontext
- the dynamic evaluation contextsetApplyFunctionConversionRulesToExternalVariables(boolean)
} is set, the supplied
value is converted to the required type. Otherwise, the supplied value is checked
against the required type.XPathException
public void setBaseOutputURI(java.lang.String uri)
This defaults to the system ID of the Result object for the principal output of the transformation if this is known; if it is not known, it defaults to the current directory.
The base output URI is used for resolving relative URIs in the href
attribute
of the xsl:result-document
instruction.
uri
- the base output URIpublic java.lang.String getBaseOutputURI()
This returns the value set using the setBaseOutputURI(java.lang.String)
method. If no value has been set
explicitly, then the method returns null if called before the transformation, or the computed
default base output URI if called after the transformation.
The base output URI is used for resolving relative URIs in the href
attribute
of the xsl:result-document
instruction.
public java.lang.String getCookedBaseOutputURI()
public Receiver getPrincipalResult()
This method is intended for internal use only. It is typically called by Saxon during the course of a transformation, to discover the result that was supplied in the transform() call.
public boolean checkUniqueOutputDestination(DocumentURI uri)
uri
- the URI to be used as the output destinationThis method is intended for internal use only.
public void addUnavailableOutputDestination(DocumentURI uri)
uri
- A URI that is not available as an output destinationpublic void removeUnavailableOutputDestination(DocumentURI uri)
uri
- A URI that is being made available as an output destinationpublic boolean isUnusedOutputDestination(DocumentURI uri)
uri
- A uri that the application is proposing to use in the href attribute of
xsl:result-document: if this function returns false, then the xsl:result-document
call will fail saying the URI has already been used.public void checkImplicitResultTree() throws XPathException
XPathException
- if the implicit result document cannot be written because an explicit result document
has been written to the same URI.public void setThereHasBeenAnExplicitResultDocument()
public boolean hasThereBeenAnExplicitResultDocument()
public SequenceOutputter allocateSequenceOutputter(int size)
size
- the estimated size of the output sequencepublic void reuseSequenceOutputter(SequenceOutputter out)
out
- the SequenceOutputter that is available for reusepublic void setBuildTree(boolean build)
build
- set to true if a tree should be built, false if the results should be delivered in raw formpublic boolean isBuildTree()
public void setInitialTemplate(StructuredQName qName) throws XPathException
transform(Source, Receiver)
method.
XSLT 2.0 allows a transformation to start by executing a named template, rather than by matching an initial context node in a source document. This method may eventually be superseded by a standard JAXP method once JAXP supports XSLT 2.0.
Note that any parameters supplied using initializeController(net.sf.saxon.expr.instruct.GlobalParameterSet)
are used as the values of global stylesheet parameters. There is no way to supply values for local parameters
of the initial template.
qName
- The expanded name of the template, or null to indicate that there should be no initial template.XPathException
- if there is no named template with this namepublic StructuredQName getInitialTemplate()
public void setInitialTemplateParameters(java.util.Map<StructuredQName,Sequence> params, boolean tunnel)
params
- Tunnel or non-tunnel parameters to be supplied to the initial template. The supplied
values will be converted to the required type using the function conversion rules.
Any surplus parameters are silently ignored. May be null.tunnel
- true if these are tunnel parameters; false if they are non-tunnel parameterspublic java.util.Map<StructuredQName,Sequence> getInitialTemplateParameters(boolean tunnel)
tunnel
- true if the parameters to be returned are the tunnel parameters; false for the non-tunnel parameterssetInitialTemplateParameters(java.util.Map, boolean)
.
May be null.public PipelineConfiguration makePipelineConfiguration()
This interface is intended primarily for internal use, although it may be necessary for applications to call it directly if they construct pull or push pipelines
public void setMessageReceiverClassName(java.lang.String name)
name
- the full name of the class to be instantiated to provide a receiver for xsl:message output. The name must
be the name of a class that implements the Receiver
interfacepublic void setMessageEmitter(Receiver receiver)
Recent versions of the JAXP interface specify that by default the output of xsl:message is sent to the registered ErrorListener. Saxon does not implement this convention. Instead, the output is sent to a default message emitter, which is a slightly customised implementation of the standard Saxon Emitter interface.
This interface can be used to change the way in which Saxon outputs xsl:message output.
It is not necessary to use this interface in order to change the destination
to which messages are written: that can be achieved by obtaining the standard
message emitter and calling its Emitter.setWriter(java.io.Writer)
method.
Although any Receiver
can be supplied as the destination for messages,
applications may find it convenient to implement a subclass of SequenceWriter
,
in which only the abstract write()
method is implemented. This will have the effect that the
write()
method is called to output each message as it is generated, with the Item
that is passed to the write()
method being the document node at the root of an XML document
containing the contents of the message.
This method is intended for use by advanced applications. The Receiver interface itself is subject to change in new Saxon releases.
The supplied Receiver will have its open() method called once at the start of
each transformation, and its close() method will be called once at the end of each
transformation. A "transformation" in this sense is a single call on a method such as
callTemplate(net.sf.saxon.om.StructuredQName, net.sf.saxon.event.Receiver)
, or applyTemplates(net.sf.saxon.om.Sequence, net.sf.saxon.event.Receiver)
. In addition, if tracing is enabled,
global variables are pre-evaluated, and the message receiver is opened at the start
of this process, and closed at the end.
Each individual call of an xsl:message instruction is wrapped by
calls of startDocument() and endDocument(). If terminate="yes" is specified on the
xsl:message call, the properties argument of the startDocument() call will be set
to the value ReceiverOptions.TERMINATE
.
receiver
- The receiver to receive xsl:message output.public Receiver getMessageEmitter()
setMessageEmitter(net.sf.saxon.event.Receiver)
method, or the
default message emitter otherwise.public void incrementMessageCounter(StructuredQName code)
code
- the error code whose counter is to be incrementedpublic java.util.Map<StructuredQName,java.lang.Integer> getMessageCounters()
public void setRecoveryPolicy(int policy)
Since 9.3 this call has no effect unless the error listener in use is a StandardErrorListener
or a subclass thereof. Calling this method then results in a call to the StandardErrorListener
to set the recovery policy, and the action that is taken on calls of the various methods
error(), fatalError(), and warning() is then the responsibility of the ErrorListener itself.
Since 9.2 the policy for handling the most common recoverable error, namely the ambiguous template
match that arises when a node matches more than one match pattern, is a compile-time rather than run-time
setting, and can be controlled using CompilerInfo.setRecoveryPolicy(int)
policy
- the recovery policy to be used. The options are Configuration.RECOVER_SILENTLY
,
Configuration.RECOVER_WITH_WARNINGS
, or Configuration.DO_NOT_RECOVER
.public int getRecoveryPolicy()
public void setErrorListener(javax.xml.transform.ErrorListener listener)
listener
- the ErrorListener to be usedpublic UnfailingErrorListener getErrorListener()
setErrorListener(ErrorListener)
method; if that was not an UnfailingErrorListener
,
it will have been wrapped in a DelegatingErrorListener
, and it is the DelegatingErrorListener
that this method returns.public void recoverableError(XPathException err) throws XPathException
This method is intended for internal use only.
err
- An exception holding information about the errorXPathException
- if the error listener decides not to
recover from the errorpublic void reportFatalError(XPathException err)
err
- the error to be reportedpublic void warning(java.lang.String message, java.lang.String errorCode, Location locator)
message
- the warning messageerrorCode
- the local part of the error code (in the ERR namespace). May be null.locator
- the location in the source code. May be null.public Executable getExecutable()
This method is intended for internal use only.
public DocumentPool getDocumentPool()
This method is intended for internal use only.
public void clearDocumentPool()
public Bindery getBindery(PackageData packageData)
This method is intended for internal use only.
packageData
- the package for which the variables are requiredpublic void setGlobalContextItem(Item contextItem)
applyTemplates(Sequence, Receiver)
and callTemplate(StructuredQName, Receiver)
.
It is not used by the transform(Source, Receiver)
and transformDocument(NodeInfo, Receiver)
methods; by contrast, these overwrite the global context item with a value based on the node supplied
as the source of the transformation.contextItem
- the context item for evaluating global variables, or null if there is nonepublic void setGlobalContextItem(Item contextItem, boolean alreadyStripped)
applyTemplates(Sequence, Receiver)
and callTemplate(StructuredQName, Receiver)
.
It is not used by the transform(Source, Receiver)
and transformDocument(NodeInfo, Receiver)
methods; by contrast, these overwrite the global context item with a value based on the node supplied
as the source of the transformation.contextItem
- the context item for evaluating global variables, or null if there is nonealreadyStripped
- true if any stripping of type annotations or whitespace text node specified
in the stylesheet has already been carried outpublic Item getGlobalContextItem()
public void setURIResolver(javax.xml.transform.URIResolver resolver)
resolver
- An object that implements the URIResolver interface, or
null.public javax.xml.transform.URIResolver getURIResolver()
This method changed in Saxon 8.5, to conform to the JAXP specification. If there is no user-specified URIResolver, it now returns null; previously it returned the system default URIResolver.
public javax.xml.transform.URIResolver getStandardURIResolver()
This method is intended for internal use only.
public void setOutputURIResolver(OutputURIResolver resolver)
XSLT 2.0 introduces the xsl:result-document
In Saxon 9.5, because xsl:result-document is now multi-threaded, the
supplied resolver is cloned each time a new result document is created.
The cloned resolved is therefore able to maintain information about
the specific result document for use when its close() method is called,
without worrying about thread safety.
resolver
- An object that implements the OutputURIResolver
interface, or null.public OutputURIResolver getOutputURIResolver()
setOutputURIResolver(net.sf.saxon.lib.OutputURIResolver)
public void setUnparsedTextURIResolver(UnparsedTextURIResolver resolver)
resolver
- the unparsed text URI resolver to be used. This replaces any unparsed text
URI resolver previously registered.public UnparsedTextURIResolver getUnparsedTextURIResolver()
setUnparsedTextURIResolver(net.sf.saxon.lib.UnparsedTextURIResolver)
method.public void setCollectionURIResolver(CollectionURIResolver resolver)
setCollectionFinder(CollectionFinder)
resolver
- the resolver for references to collectionspublic CollectionURIResolver getCollectionURIResolver()
getCollectionFinder()
public CollectionFinder getCollectionFinder()
public void setCollectionFinder(CollectionFinder cf)
cf
- the CollectionFinder to be usedpublic void setDefaultCollection(java.lang.String uri)
uri
- the collection URI of the default collection. May be null, to cause
fallback to the collection name registered with the Configuration. The name will be passed
to the collection URI resolver to identify the documents in the collection, unless
the name is http://saxon.sf.net/collection/empty
which always refers
to the empty collection.public java.lang.String getDefaultCollection()
public int getSchemaValidationMode()
public void setSchemaValidationMode(int validationMode)
validationMode
- the validation (or construction) mode to be used for source documents.
One of Validation.STRIP
, Validation.PRESERVE
, Validation.STRICT
,
Validation.LAX
public KeyManager getKeyManager()
This method is intended for internal use only.
public void setModel(TreeModel model)
model
- typically one of the constants TreeModel.TINY_TREE
,
TreeModel.TINY_TREE_CONDENSED
, or TreeModel.LINKED_TREE
.
It is also possible to use a user-defined tree model.public TreeModel getModel()
TreeModel.TINY_TREE
,
TreeModel.TINY_TREE_CONDENSED
, or TreeModel.LINKED_TREE
.
It is also possible to use a user-defined tree model.public Builder makeBuilder()
public void setStripSourceTrees(boolean strip)
Generally, stripping whitespace speeds up the transformation if it is done while building the source tree, but slows it down if it is applied to a tree that has already been built. So if the same source tree is used as input to a number of transformations, it is better to strip the whitespace once at the time of tree construction, rather than doing it on-the-fly during each transformation.
strip
- true if whitespace is to be stripped from supplied source trees
as defined by xsl:strip-space; false to suppress whitespace strippingpublic boolean isStripSourceTree()
setStripSourceTrees(boolean)
.public boolean isStylesheetStrippingTypeAnnotations()
public Stripper makeStripper(Receiver next)
xsl:strip-space
and xsl:preserve-space
elements
in the stylesheet. Alternatively, stripping of all whitespace text nodes
may be defined at the level of the Configuration, using the code
Configuration.getParseOptions().setSpaceStrippingRules(AllElementsSpaceStrippingRule.getInstance()
.next
- the Receiver to which the events filtered by this stripper are
to be sent (often a Builder). May be null if the stripper is not being used for filtering
into a Builder or other Receiver.public SpaceStrippingRule getSpaceStrippingRule()
public void registerDocument(TreeInfo doc, DocumentURI uri) throws XPathException
This method is intended for internal use only.
doc
- the root node of the document to be added. Must not be null.uri
- the document-URI property of this document. If non-null, the document is registered
in the document pool with this as its document URI.XPathException
- if an error occurspublic RuleManager getRuleManager()
This method is intended for internal use only.
public void setTraceListener(TraceListener listener)
This method has no effect unless the stylesheet or query was compiled with tracing enabled.
listener
- the TraceListener to be set. May be null, in which case
trace events will not be reportedpublic TraceListener getTraceListener()
addTraceListener(net.sf.saxon.lib.TraceListener)
. If more than one TraceListener has been added,
this method will return a composite TraceListener. Because the form
this takes is implementation-dependent, this method is not part of the
stable Saxon public API.public final boolean isTracing()
addTraceListener(net.sf.saxon.lib.TraceListener)
method, and (b) tracing has not been temporarily
paused using the pauseTracing(boolean)
method.public final void pauseTracing(boolean pause)
pause
- true if tracing is to pause; false if it is to resumepublic void addTraceListener(TraceListener trace)
Configuration.setTraceListener(net.sf.saxon.lib.TraceListener)
or by setting
the attribute FeatureKeys.TRACE_LISTENER
on the
TransformerFactory. Conversely, if this property has been set in the
Configuration or TransformerFactory, the TraceListener will automatically
be added to every Controller that uses that Configuration.trace
- the trace listener. If null is supplied, the call has no effect.public void removeTraceListener(TraceListener trace)
trace
- the trace listener.public void setTraceFunctionDestination(Logger stream)
stream
- the PrintStream to which trace output will be sent. If set to
null, trace output is suppressed entirely. It is the caller's responsibility
to close the stream after use.public Logger getTraceFunctionDestination()
public boolean isAssertionsEnabled()
public void setAssertionsEnabled(boolean enabled)
enabled
- true if assertions are to be enabled at run time; this has no effect
if assertions were disabled (for a particular package) at compile timepublic void initializeController(GlobalParameterSet params) throws XPathException
params
- the values of stylesheet parameters. This must include static parameters as well as non-static parameters.XPathException
- if an error occurs, for example if a required parameter is not supplied.public void setApplyFunctionConversionRulesToExternalVariables(boolean applyConversionRules)
public java.lang.Object getUserData(java.lang.Object key, java.lang.String name)
This method is intended primarily for internal use, though it may also be used by advanced applications.
key
- an object acting as a key for this user data value. This must be equal
(in the sense of the equals() method) to the key supplied when the data value was
registered using setUserData(java.lang.Object, java.lang.String, java.lang.Object)
.name
- the name of the required propertypublic void setUserData(java.lang.Object key, java.lang.String name, java.lang.Object data)
This method is intended primarily for internal use, though it may also be used by advanced applications.
key
- an object acting as a key for this user data value. This can be any object, for example
a node or a string. If data for the given object and name already exists, it is overwritten.name
- the name of the required propertydata
- the value of the required property. If null is supplied, any existing entry
for the key is removed.public void transform(javax.xml.transform.Source source, Receiver receiver) throws XPathException
source
- The input for the source tree. May be null if and only if an
initial template has been supplied.receiver
- The destination for the streamed result tree.XPathException
- if the transformation fails. As a
special case, the method throws a TerminationException (a subclass
of XPathException) if the transformation was terminated using
xsl:message terminate="yes".public NodeInfo makeSourceTree(javax.xml.transform.Source source, boolean close, int validationMode) throws XPathException
source
- the sourceclose
- true if the source is to be closed after usevalidationMode
- indicates whether the source should be schema-validatedXPathException
- if tree construction failspublic void applyTemplates(Sequence source, Receiver outputDestination) throws XPathException
source
- The input for the source tree. May be null if and only if an
initial template has been supplied.outputDestination
- The destination for the result sequence.XPathException
- if the transformation fails. As a
special case, the method throws a TerminationException (a subclass
of XPathException) if the transformation was terminated using
xsl:message terminate="yes".public NodeInfo prepareInputTree(javax.xml.transform.Source source)
This method is intended for internal use.
source
- the input tree. Must be either a DOMSource or a NodeInfopublic void transformDocument(NodeInfo startNode, Receiver outputDestination) throws XPathException
This method is intended for internal use. External applications should use
the transform(javax.xml.transform.Source, net.sf.saxon.event.Receiver)
method, which is part of the JAXP interface. Note that
NodeInfo
implements the JAXP Source
interface, so
it may be supplied directly to the transform() method.
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.outputDestination
- The output destinationXPathException
- if any dynamic error occurspublic void callTemplate(StructuredQName initialTemplateName, Receiver outputDestination) throws XPathException
This method is intended for internal use. External applications should use
the transform(javax.xml.transform.Source, net.sf.saxon.event.Receiver)
method, which is part of the JAXP interface. Note that
NodeInfo
implements the JAXP Source
interface, so
it may be supplied directly to the transform() method.
initialTemplateName
- the entry point, the name of a named templateoutputDestination
- The output destinationXPathException
- if any dynamic error occurspublic Receiver getStreamingReceiver(Mode mode, Receiver result) throws XPathException
This method is intended for internal use. External applications should use
the transform(javax.xml.transform.Source, net.sf.saxon.event.Receiver)
method, which is part of the JAXP interface. Note that
NodeInfo
implements the JAXP Source
interface, so
it may be supplied directly to the transform() method.
mode
- the initial mode, which must be a streaming moderesult
- The output destinationXPathException
- if any dynamic error occurspublic void preEvaluateGlobals(XPathContext context) throws XPathException
This method is intended for internal use.
context
- the dynamic context for evaluating the global variablesXPathException
- - should not happen.public void registerGlobalVariableDependency(GlobalVariable one, GlobalVariable two) throws XPathException
one
- the first (dependent) variabletwo
- the second (dependee) variableXPathException
- if adding this dependency creates a cycle of dependencies among global variables.public void setCurrentDateTime(DateTimeValue dateTime) throws XPathException
Note that comparisons of date/time values currently use the implicit timezone taken from the system clock, not from the value supplied here.
dateTime
- the date/time value to be used as the current date and timejava.lang.IllegalStateException
- if a current date/time has already been
established by calling getCurrentDateTime(), or by a previous call on setCurrentDateTime()XPathException
- if the supplied dateTime contains no timezonepublic DateTimeValue getCurrentDateTime()
public int getImplicitTimezone()
public XPathContextMajor newXPathContext()
This method is intended for internal use.
public void setRememberedNumber(NodeInfo node, int number)
This method is strictly for internal use only.
node
- the node in questionnumber
- the number of this nodepublic int getRememberedNumber(NodeInfo node)
This method is strictly for internal use only.
node
- the node for which remembered information is requiredpublic void setUseDocumentProjection(PathMap pathMap)
pathMap
- a path map to be used for projecting source documentspublic PathMap getPathMapForDocumentProjection()
public java.util.Stack<AttributeSet> getAttributeSetEvaluationStack()
public void releaseAttributeSetEvaluationStack()
public StylesheetCache getStylesheetCache()
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.