applyTemplateToNode
public boolean applyTemplateToNode(ElemTemplateElement xslInstruction,
ElemTemplate template,
int child)
throws TransformerException
Given an element and mode, find the corresponding
template and process the contents.
xslInstruction
- The calling element.template
- The template to use if xsl:for-each, or null.child
- The source context node.
- true if applied a template, false if not.
createSerializationHandler
public SerializationHandler createSerializationHandler(Result outputTarget)
throws TransformerException
Create a result ContentHandler from a Result object, based
on the current OutputProperties.
outputTarget
- Where the transform result should go,
should not be null.
- A valid ContentHandler that will create the
result tree when it is fed SAX events.
createSerializationHandler
public SerializationHandler createSerializationHandler(Result outputTarget,
OutputProperties format)
throws TransformerException
Create a ContentHandler from a Result object and an OutputProperties.
outputTarget
- Where the transform result should go,
should not be null.format
- The OutputProperties object that will contain
instructions on how to serialize the output.
- A valid ContentHandler that will create the
result tree when it is fed SAX events.
currentFuncResultSeen
public boolean currentFuncResultSeen()
Determines whether an EXSLT func:result
instruction has been
executed for the currently active EXSLT func:function
.
true
if and only if a func:result
instruction has been executed
currentTemplateRuleIsNull
public boolean currentTemplateRuleIsNull()
Tell if the current template rule is null, i.e. if we are
directly within an apply-templates. Used for xsl:apply-imports.
- True if the current template rule is null.
executeChildTemplates
public void executeChildTemplates(ElemTemplateElement elem,
boolean shouldAddAttrs)
throws TransformerException
Execute each of the children of a template element.
elem
- The ElemTemplateElement that contains the children
that should execute.shouldAddAttrs
- true if xsl:attributes should be executed.
executeChildTemplates
public void executeChildTemplates(ElemTemplateElement elem,
Node context,
QName mode,
ContentHandler handler)
throws TransformerException
Execute each of the children of a template element. This method
is only for extension use.
elem
- The ElemTemplateElement that contains the children
that should execute.mode
- The current mode.handler
- The ContentHandler to where the result events
should be fed.
executeChildTemplates
public void executeChildTemplates(ElemTemplateElement elem,
ContentHandler handler)
throws TransformerException
Execute each of the children of a template element.
elem
- The ElemTemplateElement that contains the children
that should execute.handler
- The ContentHandler to where the result events
should be fed.
executeFromSnapshot
public void executeFromSnapshot(TransformSnapshot ts)
throws TransformerException
This is an internal tooling API that nobody seems to be using
This will execute the following XSLT instructions
from the snapshot point, after the stylesheet execution
context has been reset from the snapshot point.
ts
- The snapshot of where to start execution
fireGenerateEvent
public void fireGenerateEvent(int eventType,
String data)
Fire off comment and entity ref events.
- fireGenerateEvent in interface SerializerTrace
fireGenerateEvent
public void fireGenerateEvent(int eventType,
String name,
String data)
Fire off processingInstruction events.
- fireGenerateEvent in interface SerializerTrace
fireGenerateEvent
public void fireGenerateEvent(int eventType,
char[] ch,
int start,
int length)
Fire off characters, cdate events.
org.apache.xml.serializer.SerializerTrace.fireGenerateEvent(int, char[], int, int)
getBaseURLOfSource
public String getBaseURLOfSource()
Get the base URL of the source.
- The base URL of the source tree, or null.
getContentHandler
public ContentHandler getContentHandler()
Get the content event handler.
- The current content handler, or null if none was set.
getContextNodeList
public DTMIterator getContextNodeList()
Get the current context node list.
- A reset clone of the context node list.
getCountersTable
public CountersTable getCountersTable()
Get the table of counters, for optimized xsl:number support.
- The CountersTable, never null.
getCurrentElement
public ElemTemplateElement getCurrentElement()
Retrieves the current ElemTemplateElement that is
being executed.
- The current ElemTemplateElement that is executing,
should not normally be null.
getCurrentNode
public int getCurrentNode()
This method retrieves the current context node
in the source tree.
- The current context node (should never be null?).
getCurrentTemplate
public ElemTemplate getCurrentTemplate()
This method retrieves the xsl:template
that is in effect, which may be a matched template
or a named template.
Please note that the ElemTemplate returned may
be a default template, and thus may not have a template
defined in the stylesheet.
- The current xsl:template, should not be null.
getCurrentTemplateElements
public ObjectStack getCurrentTemplateElements()
Get the count of how many elements are
active.
- The number of active elements on
the currentTemplateElements stack.
getCurrentTemplateElementsCount
public int getCurrentTemplateElementsCount()
Get the count of how many elements are
active.
- The number of active elements on
the currentTemplateElements stack.
getElementCallstack
public Vector getElementCallstack()
Get the stack of ElemTemplateElements.
- A copy of stack that contains the xsl element instructions,
the earliest called in index zero, and the latest called in index size()-1.
getExceptionThrown
public Exception getExceptionThrown()
Get the exception thrown by the secondary thread (normally
the transform thread).
- The thrown exception, or null if no exception was
thrown.
getExtensionsTable
public ExtensionsTable getExtensionsTable()
Get the extensions table object.
getFeature
public boolean getFeature(String name)
throws SAXNotRecognizedException,
SAXNotSupportedException
Look up the value of a feature.
The feature name is any fully-qualified URI. It is
possible for an TransformerFactory to recognize a feature name but
to be unable to return its value; this is especially true
in the case of an adapter for a SAX1 Parser, which has
no way of knowing whether the underlying parser is
validating, for example.
Open issues:
Should getFeature be changed to hasFeature?
name
- The feature name, which is a fully-qualified
URI.
- The current state of the feature (true or false).
getInputContentHandler
public ContentHandler getInputContentHandler()
Get a SAX2 ContentHandler for the input.
- A valid ContentHandler, which should never be null, as
long as getFeature("http://xml.org/trax/features/sax/input")
returns true.
getInputContentHandler
public ContentHandler getInputContentHandler(boolean doDocFrag)
Get a SAX2 ContentHandler for the input.
doDocFrag
- true if a DocumentFragment should be created as
the root, rather than a Document.
- A valid ContentHandler, which should never be null, as
long as getFeature("http://xml.org/trax/features/sax/input")
returns true.
getInputDeclHandler
public DeclHandler getInputDeclHandler()
Get a SAX2 DeclHandler for the input.
- A valid DeclHandler, which should never be null, as
long as getFeature("http://xml.org/trax/features/sax/input")
returns true.
getInputLexicalHandler
public LexicalHandler getInputLexicalHandler()
Get a SAX2 LexicalHandler for the input.
- A valid LexicalHandler, which should never be null, as
long as getFeature("http://xml.org/trax/features/sax/input")
returns true.
getKeyManager
public KeyManager getKeyManager()
Get the KeyManager object.
- A reference to the KeyManager object, which should
never be null.
getMatchedNode
public int getMatchedNode()
Retrieves the node in the source tree that matched
the template obtained via getMatchedTemplate().
- The matched node that corresponds to the
match attribute of the current xsl:template.
getMatchedTemplate
public ElemTemplate getMatchedTemplate()
This method retrieves the xsl:template
that was matched. Note that this may not be
the same thing as the current template (which
may be from getCurrentElement()), since a named
template may be in effect.
- The pushed template that was pushed via pushPairCurrentMatched.
getMode
public QName getMode()
NEEDSDOC Method getMode
NEEDSDOC (getMode) @return
getMsgMgr
public MsgMgr getMsgMgr()
Return the message manager.
- The message manager, never null.
getOutputFormat
public OutputProperties getOutputFormat()
Get the output properties used for the transformation.
- the output format that was set by the user,
otherwise the output format from the stylesheet.
getOutputProperties
public Properties getOutputProperties()
Get a copy of the output properties for the transformation. These
properties will override properties set in the templates
with xsl:output.
Note that mutation of the Properties object returned will not
effect the properties that the transformation contains.
- getOutputProperties in interface Transformer
- A copy of the set of output properties in effect
for the next transformation.
NEEDSDOC ($objectName$) @return
getOutputProperty
public String getOutputProperty(String qnameString)
throws IllegalArgumentException
Get an output property that is in effect for the
transformation. The property specified may be a property
that was set with setOutputProperty, or it may be a
property specified in the stylesheet.
- getOutputProperty in interface Transformer
- The string value of the output property, or null
if no property was found.
getOutputPropertyNoDefault
public String getOutputPropertyNoDefault(String qnameString)
throws IllegalArgumentException
Get the value of a property, without using the default properties. This
can be used to test if a property has been explicitly set by the stylesheet
or user.
- The value of the property, or null if not found.
getOutputTarget
public Result getOutputTarget()
Get the original output target.
- The Result object used to kick of the transform or null.
getParameter
public Object getParameter(String name)
Get a parameter that was explicitly set with setParameter
or setParameters.
NEEDSDOC @param name
- getParameter in interface Transformer
- A parameter that has been set with setParameter
or setParameters,
not* all the xsl:params on the stylesheet (which require
a transformation Source to be evaluated).
getProperty
public boolean getProperty(String property)
getProperty
returns the current setting of the
property described by the property
argument.
%REVIEW% Obsolete now that source_location is handled in the TransformerFactory?
property
- a String
value
getQuietConflictWarnings
public boolean getQuietConflictWarnings()
Get quietConflictWarnings property. If the quietConflictWarnings
property is set to true, warnings about pattern conflicts won't be
printed to the diagnostics stream.
- True if this transformer should not report
template match conflicts.
getRecursionLimit
public int getRecursionLimit()
Get the recursion limit.
Used for infinite loop check. If the value is -1, do not
check for infinite loops. Anyone who wants to enable that
check should change the value of this variable to be the
level of recursion that they want to check. Be careful setting
this variable, if the number is too low, it may report an
infinite loop situation, when there is none.
Post version 1.0.0, we'll make this a runtime feature.
- The limit on recursion, or -1 if no check is to be made.
getResultTreeHandler
public SerializationHandler getResultTreeHandler()
Get the SerializationHandler object.
- The current SerializationHandler, which may not
be the main result tree manager.
getSerializationHandler
public SerializationHandler getSerializationHandler()
Get the SerializationHandler object.
- The current SerializationHandler, which may not
be the main result tree manager.
getShouldStripSpace
public short getShouldStripSpace(int elementHandle,
DTM dtm)
Test whether whitespace-only text nodes are visible in the logical
view of DTM
. Normally, this function
will be called by the implementation of DTM
;
it is not normally called directly from
user code.
- getShouldStripSpace in interface DTMWSFilter
elementHandle
- int Handle of the element.
- one of NOTSTRIP, STRIP, or INHERIT.
getSnapshot
public TransformSnapshot getSnapshot()
This is an internal tooling API that nobody seems to be using
This will get a snapshot of the current executing context
- TransformSnapshot object, snapshot of executing context
getStackGuard
public StackGuard getStackGuard()
Get the object used to guard the stack from
recursion.
- The StackGuard object, which should never be null.
getStringWriterPool
public ObjectPool getStringWriterPool()
Get the StringWriter pool, so that StringWriter
objects may be reused.
- The string writer pool, not null.
getStylesheet
public final StylesheetRoot getStylesheet()
Get the current stylesheet for this processor.
- The stylesheet that is associated with this
transformer.
getTemplateCallstack
public Vector getTemplateCallstack()
Get the call stack of xsl:template elements.
- A copy of stack that contains the xsl:template
(ElemTemplate) instructions, the earliest called in index
zero, and the latest called in index size()-1.
getTraceManager
public TraceManager getTraceManager()
Get an instance of the trace manager for this transformation.
This object can be used to set trace listeners on various
events during the transformation.
- A reference to the TraceManager, never null.
getTransformThread
public Thread getTransformThread()
Get the thread that the transform process is on.
- The thread that the transform process is on, or null.
getTransformer
public Transformer getTransformer()
Get the TrAX Transformer object in effect.
getURIResolver
public URIResolver getURIResolver()
Get an object that will be used to resolve URIs used in
document(), etc.
- getURIResolver in interface Transformer
- An object that implements the URIResolver interface,
or null.
getXPathContext
public final XPathContext getXPathContext()
Get the XPath context associated with this transformer.
- The XPathContext reference, never null.
hasTransformThreadErrorCatcher
public boolean hasTransformThreadErrorCatcher()
Return true if the transform was initiated from the transform method,
otherwise it was probably done from a pure parse events.
NEEDSDOC ($objectName$) @return
isParserEventsOnMain
public boolean isParserEventsOnMain()
Get true if the parser events should be on the main thread,
false if not. Experimental. Can not be set right now.
- true if the parser events should be on the main thread,
false if not.
isRecursiveAttrSet
public boolean isRecursiveAttrSet(ElemAttributeSet attrSet)
Check to see if this is a recursive attribute definition.
attrSet
- A non-null ElemAttributeSet reference.
- true if the attribute set is recursive.
isTransformDone
public boolean isTransformDone()
Tell if the transform method is completed.
- True if transformNode has completed, or
an exception was thrown.
popCurrentFuncResult
public Object popCurrentFuncResult()
Pops the result of the currently active EXSLT func:function
.
- the value of the
func:function
popCurrentMatched
public void popCurrentMatched()
Pop the elements that were pushed via pushPairCurrentMatched.
popCurrentTemplateRuleIsNull
public void popCurrentTemplateRuleIsNull()
Push true if the current template rule is null, false
otherwise.
popElemAttributeSet
public void popElemAttributeSet()
Pop the current executing attribute set.
popElemTemplateElement
public void popElemTemplateElement()
Pop the current template element.
popMode
public void popMode()
NEEDSDOC Method popMode
processSortKeys
public Vector processSortKeys(ElemForEach foreach,
int sourceNodeContext)
throws TransformerException
Get the keys for the xsl:sort elements.
Note: Should this go into ElemForEach?
foreach
- Valid ElemForEach element, not null.sourceNodeContext
- The current node context in the source tree,
needed to evaluate the Attribute Value Templates.
- A Vector of NodeSortKeys, or null.
pushCurrentFuncResult
public void pushCurrentFuncResult(Object val)
Push a funcion result for the currently active EXSLT
func:function
.
val
- the result of executing an EXSLT
func:result
instruction for the current
func:function
.
pushCurrentTemplateRuleIsNull
public void pushCurrentTemplateRuleIsNull(boolean b)
Push true if the current template rule is null, false
otherwise.
b
- True if the we are executing an xsl:for-each
(or xsl:call-template?).
pushElemAttributeSet
public void pushElemAttributeSet(ElemAttributeSet attrSet)
Push an executing attribute set, so we can check for
recursive attribute definitions.
attrSet
- A non-null ElemAttributeSet reference.
pushElemTemplateElement
public void pushElemTemplateElement(ElemTemplateElement elem)
Push the current template element.
elem
- The current ElemTemplateElement (may be null, and then
set via setCurrentElement).
pushMode
public void pushMode(QName mode)
NEEDSDOC Method pushMode
NEEDSDOC @param mode
pushPairCurrentMatched
public void pushPairCurrentMatched(ElemTemplateElement template,
int child)
Push both the current xsl:template or xsl:for-each onto the
stack, along with the child node that was matched.
(Note: should this only be used for xsl:templates?? -sb)
template
- xsl:template or xsl:for-each.child
- The child that was matched.
reset
public void reset()
Reset the state. This needs to be called after a process() call
is invoked, if the processor is to be used again.
resetToStylesheet
public void resetToStylesheet(TransformSnapshot ts)
This is an internal tooling API that nobody seems to be using
This will reset the stylesheet execution context
from the snapshot point.
ts
- The snapshot of where to start execution
run
public void run()
Run the transform thread.
runTransformThread
public void runTransformThread()
Called by this.transform() if isParserEventsOnMain()==false.
Similar with runTransformThread(), but no priority is set
and setTransformThread is not set.
runTransformThread
public static void runTransformThread(Runnable runnable)
Called by CoRoutineSAXParser. Launches the CoroutineSAXParser
in a thread, and prepares it to invoke the parser from that thread
upon request.
runTransformThread
public void runTransformThread(int priority)
Called by SourceTreeHandler to start the transformation
in a separate thread
NEEDSDOC @param priority
setBaseURLOfSource
public void setBaseURLOfSource(String base)
Get the base URL of the source.
NEEDSDOC @param base
setContentHandler
public void setContentHandler(ContentHandler handler)
Set the content event handler.
setCurrentElement
public void setCurrentElement(ElemTemplateElement e)
Set the top of the current template elements
stack.
e
- The current ElemTemplateElement about to
be executed.
setErrorListener
public void setErrorListener(ErrorListener listener)
throws IllegalArgumentException
Set the error event listener.
- setErrorListener in interface Transformer
listener
- The new error listener.
setExceptionThrown
public void setExceptionThrown(Exception e)
Set the exception thrown by the secondary thread (normally
the transform thread).
e
- The thrown exception, or null if no exception was
thrown.
setIsTransformDone
public void setIsTransformDone(boolean done)
Set if the transform method is completed.
done
- True if transformNode has completed, or
an exception was thrown.
setOutputFormat
public void setOutputFormat(OutputProperties oformat)
Set the output properties for the transformation. These
properties will override properties set in the templates
with xsl:output.
oformat
- A valid OutputProperties object (which will
not be mutated), or null.
setOutputProperties
public void setOutputProperties(Properties oformat)
throws IllegalArgumentException
Set the output properties for the transformation. These
properties will override properties set in the templates
with xsl:output.
If argument to this function is null, any properties
previously set will be removed.
- setOutputProperties in interface Transformer
oformat
- A set of output properties that will be
used to override any of the same properties in effect
for the transformation.
setOutputProperty
public void setOutputProperty(String name,
String value)
throws IllegalArgumentException
Set the value of a property. Recognized properties are:
"http://xml.apache.org/xslt/sourcebase" - the base URL for the
source, which is needed when pure SAX ContentHandler transformation
is to be done.
- setOutputProperty in interface Transformer
name
- The property name, which is a fully-qualified URI.value
- The requested value for the property.
setOutputTarget
public void setOutputTarget(Result outputTarget)
Set the original output target. This is useful when using a SAX transform and
supplying a ContentHandler or when the URI of the output target should
not be the same as the systemID of the original output target.
NEEDSDOC @param outputTarget
setParameter
public void setParameter(String name,
Object value)
Set a parameter for the transformation.
- setParameter in interface Transformer
name
- The name of the parameter,
which may have a namespace URI.value
- The value object. This can be any valid Java object
-- it's up to the processor to provide the proper
coersion to the object, or simply pass it on for use
in extensions.
setParameter
public void setParameter(String name,
String namespace,
Object value)
Set a parameter for the templates.
name
- The name of the parameter.namespace
- The namespace of the parameter.value
- The value object. This can be any valid Java object
-- it's up to the processor to provide the proper
coersion to the object, or simply pass it on for use
in extensions.
setParameters
public void setParameters(Properties params)
Set a bag of parameters for the transformation. Note that
these will not be additive, they will replace the existing
set of parameters.
setProperty
public void setProperty(String property,
Object value)
Set a runtime property for this TransformerImpl
.
%REVIEW% Obsolete now that source_location is handled in the TransformerFactory?
property
- a String
valuevalue
- an Object
value
setQuietConflictWarnings
public void setQuietConflictWarnings(boolean b)
If the quietConflictWarnings property is set to
true, warnings about pattern conflicts won't be
printed to the diagnostics stream.
False by default.
(Currently setting this property will have no effect.)
b
- true if conflict warnings should be suppressed.
setRecursionLimit
public void setRecursionLimit(int limit)
Set the recursion limit.
Used for infinite loop check. If the value is -1, do not
check for infinite loops. Anyone who wants to enable that
check should change the value of this variable to be the
level of recursion that they want to check. Be careful setting
this variable, if the number is too low, it may report an
infinite loop situation, when there is none.
Post version 1.0.0, we'll make this a runtime feature.
limit
- A number that represents the limit of recursion,
or -1 if no checking is to be done.
setShouldReset
public void setShouldReset(boolean shouldReset)
NEEDSDOC Method setShouldReset
NEEDSDOC @param shouldReset
setSourceTreeDocForThread
public void setSourceTreeDocForThread(int doc)
This is just a way to set the document for run().
doc
- A non-null reference to the root of the
tree to be transformed.
setStylesheet
public void setStylesheet(StylesheetRoot stylesheetRoot)
Set the stylesheet for this processor. If this is set, then the
process calls that take only the input .xml will use
this instead of looking for a stylesheet PI. Also,
setting the stylesheet is needed if you are going
to use the processor as a SAX ContentHandler.
stylesheetRoot
- A non-null StylesheetRoot object,
or null if you wish to clear the stylesheet reference.
setTransformThread
public void setTransformThread(Thread t)
Get the thread that the transform process is on.
t
- The transform thread, may be null.
setURIResolver
public void setURIResolver(URIResolver resolver)
Set an object that will be used to resolve URIs used in
document(), etc.
- setURIResolver in interface Transformer
resolver
- An object that implements the URIResolver interface,
or null.
setXMLSource
public void setXMLSource(Source source)
Set the input source for the source tree, which is needed if the
parse thread is not the main thread, in order for the parse
thread's run method to get to the input source.
source
- The input source for the source tree.
setXPathContext
public void setXPathContext(XPathContext xcontext)
Set the execution context for XPath.
xcontext
- A non-null reference to the XPathContext
associated with this transformer.
stopTransformation
public void stopTransformation()
NEEDSDOC Method stopTransformation
transform
public void transform(Source source)
throws TransformerException
Process the source tree to SAX parse events.
source
- The input for the source tree.
transform
public void transform(Source source,
boolean shouldRelease)
throws TransformerException
Process the source tree to SAX parse events.
source
- The input for the source tree.shouldRelease
- Flag indicating whether to release DTMManager.
transform
public void transform(Source xmlSource,
Result outputTarget)
throws TransformerException
Process the source tree to the output result.
- transform in interface Transformer
xmlSource
- The input for the source tree.outputTarget
- The output source target.
transform
public void transform(Source xmlSource,
Result outputTarget,
boolean shouldRelease)
throws TransformerException
Process the source tree to the output result.
xmlSource
- The input for the source tree.outputTarget
- The output source target.shouldRelease
- Flag indicating whether to release DTMManager.
transformNode
public void transformNode(int node)
throws TransformerException
Process the source node to the output result, if the
processor supports the "http://xml.org/trax/features/dom/input"
feature.
%REVIEW% Do we need a Node version of this?
node
- The input source node, which can be any valid DTM node.
transformNode
public void transformNode(int node,
Result outputTarget)
throws TransformerException
Process the source node to the output result, if the
processor supports the "http://xml.org/trax/features/dom/input"
feature.
%REVIEW% Do we need a Node version of this?
node
- The input source node, which can be any valid DTM node.outputTarget
- The output source target.
transformToGlobalRTF
public int transformToGlobalRTF(ElemTemplateElement templateParent)
throws TransformerException
Given a stylesheet element, create a result tree fragment from it's
contents. The fragment will also use the shared DTM system, but will
obtain its space from the global variable pool rather than the dynamic
variable stack. This allows late binding of XUnresolvedVariables without
the risk that their content will be discarded when the variable stack
is popped.
templateParent
- The template element that holds the fragment.
- the NodeHandle for the root node of the resulting RTF.
transformToRTF
public int transformToRTF(ElemTemplateElement templateParent)
throws TransformerException
Given a stylesheet element, create a result tree fragment from it's
contents. The fragment will be built within the shared RTF DTM system
used as a variable stack.
templateParent
- The template element that holds the fragment.
- the NodeHandle for the root node of the resulting RTF.
transformToString
public String transformToString(ElemTemplateElement elem)
throws TransformerException
Take the contents of a template element, process it, and
convert it to a string.
elem
- The parent element whose children will be output
as a string.
- The stringized result of executing the elements children.
waitTransformThread
public void waitTransformThread()
throws SAXException
Used by SourceTreeHandler to wait until the transform
completes