org.apache.xalan.transformer
public class TransformerImpl extends Transformer implements Runnable, DTMWSFilter, ExtensionsProvider, SerializerTrace
UNKNOWN: advanced
Constructor Summary | |
---|---|
TransformerImpl(StylesheetRoot stylesheet)
Construct a TransformerImpl.
|
Method Summary | |
---|---|
boolean | applyTemplateToNode(ElemTemplateElement xslInstruction, ElemTemplate template, int child)
Given an element and mode, find the corresponding
template and process the contents.
|
void | clearParameters()
Reset the parameters to a null list. |
SerializationHandler | createSerializationHandler(Result outputTarget)
Create a result ContentHandler from a Result object, based
on the current OutputProperties.
|
SerializationHandler | createSerializationHandler(Result outputTarget, OutputProperties format)
Create a ContentHandler from a Result object and an OutputProperties.
|
boolean | currentFuncResultSeen()
Determines whether an EXSLT func:result instruction has been
executed for the currently active EXSLT func:function .
|
boolean | currentTemplateRuleIsNull()
Tell if the current template rule is null, i.e. if we are
directly within an apply-templates. |
boolean | elementAvailable(String ns, String elemName) |
void | executeChildTemplates(ElemTemplateElement elem, Node context, QName mode, ContentHandler handler)
Execute each of the children of a template element. |
void | executeChildTemplates(ElemTemplateElement elem, boolean shouldAddAttrs)
Execute each of the children of a template element.
|
void | executeChildTemplates(ElemTemplateElement elem, ContentHandler handler)
Execute each of the children of a template element.
|
void | executeFromSnapshot(TransformSnapshot ts)
This will execute the following XSLT instructions
from the snapshot point, after the stylesheet execution
context has been reset from the snapshot point.
|
Object | extFunction(String ns, String funcName, Vector argVec, Object methodKey) |
Object | extFunction(FuncExtFunction extFunction, Vector argVec) |
void | fireGenerateEvent(int eventType, char[] ch, int start, int length)
Fire off characters, cdate events. |
void | fireGenerateEvent(int eventType, String name, Attributes atts)
Fire off startElement, endElement events. |
void | fireGenerateEvent(int eventType, String name, String data)
Fire off processingInstruction events. |
void | fireGenerateEvent(int eventType, String data)
Fire off comment and entity ref events. |
void | fireGenerateEvent(int eventType)
Fire off startDocument, endDocument events. |
boolean | functionAvailable(String ns, String funcName) |
String | getBaseURLOfSource()
Get the base URL of the source.
|
ContentHandler | getContentHandler()
Get the content event handler.
|
DTMIterator | getContextNodeList()
Get the current context node list.
|
CountersTable | getCountersTable()
Get the table of counters, for optimized xsl:number support.
|
ElemTemplateElement | getCurrentElement()
Retrieves the current ElemTemplateElement that is
being executed.
|
int | getCurrentNode()
This method retrieves the current context node
in the source tree.
|
ElemTemplate | getCurrentTemplate()
This method retrieves the xsl:template
that is in effect, which may be a matched template
or a named template.
|
ObjectStack | getCurrentTemplateElements()
Get the count of how many elements are
active. |
int | getCurrentTemplateElementsCount()
Get the count of how many elements are
active. |
boolean | getDebug() |
Vector | getElementCallstack()
Get the stack of ElemTemplateElements.
|
ErrorListener | getErrorListener()
Get the current error event handler.
|
Exception | getExceptionThrown()
Get the exception thrown by the secondary thread (normally
the transform thread).
|
ExtensionsTable | getExtensionsTable()
Get the extensions table object.
|
boolean | getFeature(String name)
Look up the value of a feature.
|
boolean | getIncremental() |
ContentHandler | getInputContentHandler()
Get a SAX2 ContentHandler for the input.
|
ContentHandler | getInputContentHandler(boolean doDocFrag)
Get a SAX2 ContentHandler for the input.
|
DeclHandler | getInputDeclHandler()
Get a SAX2 DeclHandler for the input. |
LexicalHandler | getInputLexicalHandler()
Get a SAX2 LexicalHandler for the input. |
KeyManager | getKeyManager()
Get the KeyManager object.
|
int | getMatchedNode()
Retrieves the node in the source tree that matched
the template obtained via getMatchedTemplate().
|
ElemTemplate | getMatchedTemplate()
This method retrieves the xsl:template
that was matched. |
QName | getMode()
NEEDSDOC Method getMode
NEEDSDOC (getMode) @return |
MsgMgr | getMsgMgr()
Return the message manager.
|
boolean | getOptimize() |
OutputProperties | getOutputFormat()
Get the output properties used for the transformation.
|
Properties | getOutputProperties()
Get a copy of the output properties for the transformation. |
String | getOutputProperty(String qnameString)
Get an output property that is in effect for the
transformation. |
String | getOutputPropertyNoDefault(String qnameString)
Get the value of a property, without using the default properties. |
Result | getOutputTarget()
Get the original output target.
|
Object | getParameter(String name)
Get a parameter that was explicitly set with setParameter
or setParameters.
|
boolean | getProperty(String property)getProperty returns the current setting of the
property described by the property argument.
|
boolean | getQuietConflictWarnings()
Get quietConflictWarnings property. |
int | getRecursionLimit()
Get the recursion limit.
|
SerializationHandler | getResultTreeHandler()
Get the SerializationHandler object.
|
SerializationHandler | getSerializationHandler()
Get the SerializationHandler object.
|
short | getShouldStripSpace(int elementHandle, DTM dtm)
Test whether whitespace-only text nodes are visible in the logical
view of DTM . |
TransformSnapshot | getSnapshot()
This will get a snapshot of the current executing context
|
boolean | getSource_location() |
StackGuard | getStackGuard()
Get the object used to guard the stack from
recursion.
|
ObjectPool | getStringWriterPool()
Get the StringWriter pool, so that StringWriter
objects may be reused.
|
StylesheetRoot | getStylesheet()
Get the current stylesheet for this processor.
|
Vector | getTemplateCallstack()
Get the call stack of xsl:template elements.
|
TraceManager | getTraceManager()
Get an instance of the trace manager for this transformation.
|
Transformer | getTransformer()
Get the TrAX Transformer object in effect.
|
Thread | getTransformThread()
Get the thread that the transform process is on.
|
URIResolver | getURIResolver()
Get an object that will be used to resolve URIs used in
document(), etc.
|
XPathContext | getXPathContext()
Get the XPath context associated with this transformer.
|
boolean | hasTraceListeners() |
boolean | hasTransformThreadErrorCatcher()
Return true if the transform was initiated from the transform method,
otherwise it was probably done from a pure parse events.
|
void | init(ToXMLSAXHandler h, Transformer transformer, ContentHandler realHandler)
Initializer method.
|
boolean | isParserEventsOnMain()
Get true if the parser events should be on the main thread,
false if not. |
boolean | isRecursiveAttrSet(ElemAttributeSet attrSet)
Check to see if this is a recursive attribute definition.
|
boolean | isTransformDone()
Tell if the transform method is completed.
|
Object | popCurrentFuncResult()
Pops the result of the currently active EXSLT func:function .
|
void | popCurrentMatched()
Pop the elements that were pushed via pushPairCurrentMatched. |
void | popCurrentTemplateRuleIsNull()
Push true if the current template rule is null, false
otherwise. |
void | popElemAttributeSet()
Pop the current executing attribute set. |
void | popElemTemplateElement()
Pop the current template element. |
void | popMode()
NEEDSDOC Method popMode
|
Vector | processSortKeys(ElemForEach foreach, int sourceNodeContext)
Get the keys for the xsl:sort elements.
|
void | pushCurrentFuncResult(Object val)
Push a funcion result for the currently active EXSLT
func:function .
|
void | pushCurrentTemplateRuleIsNull(boolean b)
Push true if the current template rule is null, false
otherwise.
|
void | pushElemAttributeSet(ElemAttributeSet attrSet)
Push an executing attribute set, so we can check for
recursive attribute definitions.
|
void | pushElemTemplateElement(ElemTemplateElement elem)
Push the current template element.
|
void | pushMode(QName mode)
NEEDSDOC Method pushMode
NEEDSDOC @param mode |
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.
|
void | reset()
Reset the state. |
void | resetToStylesheet(TransformSnapshot ts)
This will reset the stylesheet execution context
from the snapshot point.
|
void | run()
Run the transform thread. |
void | runTransformThread(int priority)
Called by SourceTreeHandler to start the transformation
in a separate thread
NEEDSDOC @param priority |
void | runTransformThread()
Called by this.transform() if isParserEventsOnMain()==false.
|
static void | runTransformThread(Runnable runnable)
Called by CoRoutineSAXParser. |
void | setBaseURLOfSource(String base)
Get the base URL of the source.
|
void | setContentHandler(ContentHandler handler)
Set the content event handler.
|
void | setCurrentElement(ElemTemplateElement e)
Set the top of the current template elements
stack.
|
void | setDebug(boolean b) |
void | setErrorListener(ErrorListener listener)
Set the error event listener.
|
void | setExceptionThrown(Exception e)
Set the exception thrown by the secondary thread (normally
the transform thread).
|
void | setIsTransformDone(boolean done)
Set if the transform method is completed.
|
void | setOutputFormat(OutputProperties oformat)
Set the output properties for the transformation. |
void | setOutputProperties(Properties oformat)
Set the output properties for the transformation. |
void | setOutputProperty(String name, String value)
This method is used to set or override the value
of the effective xsl:output attribute values
specified in the stylesheet.
|
void | setOutputTarget(Result outputTarget)
Set the original output target. |
void | setParameter(String name, String namespace, Object value)
Set a parameter for the templates.
|
void | setParameter(String name, Object value)
Set a parameter for the transformation.
|
void | setParameters(Properties params)
Set a bag of parameters for the transformation. |
void | setProperty(String property, Object value)
Set a runtime property for this TransformerImpl .
|
void | setQuietConflictWarnings(boolean b)
If the quietConflictWarnings property is set to
true, warnings about pattern conflicts won't be
printed to the diagnostics stream.
|
void | setRecursionLimit(int limit)
Set the recursion limit.
|
void | setSerializationHandler(SerializationHandler xoh) |
void | setShouldReset(boolean shouldReset)
NEEDSDOC Method setShouldReset
NEEDSDOC @param shouldReset |
void | setSourceTreeDocForThread(int doc)
This is just a way to set the document for run().
|
void | setStylesheet(StylesheetRoot stylesheetRoot)
Set the stylesheet for this processor. |
void | setTransformThread(Thread t)
Get the thread that the transform process is on.
|
void | setURIResolver(URIResolver resolver)
Set an object that will be used to resolve URIs used in
document(), etc. |
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.
|
void | setXPathContext(XPathContext xcontext)
Set the execution context for XPath.
|
void | stopTransformation()
NEEDSDOC Method stopTransformation
|
void | transform(Source source)
Process the source tree to SAX parse events. |
void | transform(Source source, boolean shouldRelease)
Process the source tree to SAX parse events. |
void | transform(Source xmlSource, Result outputTarget)
Process the source tree to the output result. |
void | transform(Source xmlSource, Result outputTarget, boolean shouldRelease)
Process the source tree to the output result. |
void | transformNode(int node, Result outputTarget)
Process the source node to the output result, if the
processor supports the "http://xml.org/trax/features/dom/input"
feature.
|
void | transformNode(int node)
Process the source node to the output result, if the
processor supports the "http://xml.org/trax/features/dom/input"
feature.
|
int | transformToGlobalRTF(ElemTemplateElement templateParent)
Given a stylesheet element, create a result tree fragment from it's
contents. |
int | transformToRTF(ElemTemplateElement templateParent)
Given a stylesheet element, create a result tree fragment from it's
contents. |
String | transformToString(ElemTemplateElement elem)
Take the contents of a template element, process it, and
convert it to a string.
|
void | waitTransformThread()
Used by SourceTreeHandler to wait until the transform
completes
|
Parameters: stylesheet The root of the stylesheet tree.
Parameters: xslInstruction The calling element. template The template to use if xsl:for-each, current template for apply-imports, or null. child The source context node.
Returns: true if applied a template, false if not.
Throws: TransformerException
UNKNOWN: advanced
Parameters: outputTarget Where the transform result should go, should not be null.
Returns: A valid ContentHandler that will create the result tree when it is fed SAX events.
Throws: TransformerException
Parameters: 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.
Returns: A valid ContentHandler that will create the result tree when it is fed SAX events.
Throws: TransformerException
func:result
instruction has been
executed for the currently active EXSLT func:function
.
Returns: true
if and only if a func:result
instruction has been executed
Returns: True if the current template rule is null.
Parameters: elem The ElemTemplateElement that contains the children that should execute. NEEDSDOC @param context mode The current mode. handler The ContentHandler to where the result events should be fed.
Throws: TransformerException
UNKNOWN: advanced
Parameters: elem The ElemTemplateElement that contains the children that should execute. shouldAddAttrs true if xsl:attributes should be executed.
Throws: TransformerException
UNKNOWN: advanced
Parameters: elem The ElemTemplateElement that contains the children that should execute. handler The ContentHandler to where the result events should be fed.
Throws: TransformerException
UNKNOWN: advanced
Deprecated: 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.Parameters: ts The snapshot of where to start execution
Throws: TransformerException
See Also: (int, char[], int, int)
See Also: SerializerTrace
See Also: SerializerTrace
See Also: SerializerTrace
See Also: SerializerTrace
Returns: The base URL of the source tree, or null.
Returns: The current content handler, or null if none was set.
See Also: org.xml.sax.XMLReader#getContentHandler
Returns: A reset clone of the context node list.
Returns: The CountersTable, never null.
Returns: The current ElemTemplateElement that is executing, should not normally be null.
Returns: The current context node (should never be null?).
Please note that the ElemTemplate returned may be a default template, and thus may not have a template defined in the stylesheet.
Returns: The current xsl:template, should not be null.
Returns: The number of active elements on the currentTemplateElements stack.
Returns: The number of active elements on the currentTemplateElements stack.
Returns: A copy of stack that contains the xsl element instructions, the earliest called in index zero, and the latest called in index size()-1.
Returns: The current error handler, which should never be null.
Returns: The thrown exception, or null if no exception was thrown.
Returns: The extensions table.
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.
Parameters: name The feature name, which is a fully-qualified URI.
Returns: The current state of the feature (true or false).
Throws: org.xml.sax.SAXNotRecognizedException When the TransformerFactory does not recognize the feature name. org.xml.sax.SAXNotSupportedException When the TransformerFactory recognizes the feature name but cannot determine its value at this time. SAXNotRecognizedException SAXNotSupportedException
Returns: Incremental flag
Returns: A valid ContentHandler, which should never be null, as long as getFeature("http://xml.org/trax/features/sax/input") returns true.
Parameters: doDocFrag true if a DocumentFragment should be created as the root, rather than a Document.
Returns: A valid ContentHandler, which should never be null, as long as getFeature("http://xml.org/trax/features/sax/input") returns true.
Returns: A valid DeclHandler, which should never be null, as long as getFeature("http://xml.org/trax/features/sax/input") returns true.
Returns: A valid LexicalHandler, which should never be null, as long as getFeature("http://xml.org/trax/features/sax/input") returns true.
Returns: A reference to the KeyManager object, which should never be null.
Returns: The matched node that corresponds to the match attribute of the current xsl:template.
Returns: The pushed template that was pushed via pushPairCurrentMatched.
Returns: The message manager, never null.
Returns: Optimization flag
Returns: the output format that was set by the user, otherwise the output format from the stylesheet.
Note that mutation of the Properties object returned will not effect the properties that the transformation contains.
Returns: A copy of the set of output properties in effect for the next transformation. NEEDSDOC ($objectName$) @return
Returns: The string value of the output property, or null if no property was found.
Throws: IllegalArgumentException If the property is not supported.
See Also: javax.xml.transform.OutputKeys
Returns: The value of the property, or null if not found.
Throws: IllegalArgumentException If the property is not supported, and is not namespaced.
Returns: The Result object used to kick of the transform or null.
Returns: 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
returns the current setting of the
property described by the property
argument.
%REVIEW% Obsolete now that source_location is handled in the TransformerFactory?
Parameters: property a String
value
Returns: a boolean
value
Returns: True if this transformer should not report template match conflicts.
Returns: The limit on recursion, or -1 if no check is to be made.
Returns: The current SerializationHandler, which may not be the main result tree manager.
Returns: The current SerializationHandler, which may not be the main result tree manager.
DTM
. Normally, this function
will be called by the implementation of DTM
;
it is not normally called directly from
user code.
Parameters: elementHandle int Handle of the element.
Returns: one of NOTSTRIP, STRIP, or INHERIT.
Deprecated: This is an internal tooling API that nobody seems to be using
This will get a snapshot of the current executing contextReturns: TransformSnapshot object, snapshot of executing context
Returns: Source location flag
Returns: The StackGuard object, which should never be null.
UNKNOWN: internal
Returns: The string writer pool, not null.
UNKNOWN: internal
Returns: The stylesheet that is associated with this transformer.
Returns: 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.
Returns: A reference to the TraceManager, never null.
Returns: This object.
Returns: The thread that the transform process is on, or null.
UNKNOWN: internal
Returns: An object that implements the URIResolver interface, or null.
Returns: The XPathContext reference, never null.
See Also: hasTraceListeners
Parameters: transformer non-null transformer instance realHandler Content Handler instance
Returns: true if the parser events should be on the main thread, false if not.
UNKNOWN: experimental
Parameters: attrSet A non-null ElemAttributeSet reference.
Returns: true if the attribute set is recursive.
Returns: True if transformNode has completed, or an exception was thrown.
func:function
.
Returns: the value of the func:function
Parameters: foreach Valid ElemForEach element, not null. sourceNodeContext The current node context in the source tree, needed to evaluate the Attribute Value Templates.
Returns: A Vector of NodeSortKeys, or null.
Throws: TransformerException
UNKNOWN: advanced
func:function
.
Parameters: val the result of executing an EXSLT
func:result
instruction for the current
func:function
.
Parameters: b True if the we are executing an xsl:for-each (or xsl:call-template?).
Parameters: attrSet A non-null ElemAttributeSet reference.
Parameters: elem The current ElemTemplateElement (may be null, and then set via setCurrentElement).
Parameters: template xsl:template or xsl:for-each. child The child that was matched.
Deprecated: This is an internal tooling API that nobody seems to be using
This will reset the stylesheet execution context from the snapshot point.Parameters: ts The snapshot of where to start execution
Returns: The base URL of the source tree, or null.
Throws: java.lang.NullPointerException If the handler is null.
See Also: org.xml.sax.XMLReader#setContentHandler
Parameters: e The current ElemTemplateElement about to be executed.
Parameters: listener The new error listener.
Throws: IllegalArgumentException if
Parameters: e The thrown exception, or null if no exception was thrown.
Parameters: done True if transformNode has completed, or an exception was thrown.
Parameters: oformat A valid OutputProperties object (which will not be mutated), or null.
If argument to this function is null, any properties previously set will be removed.
Parameters: oformat A set of output properties that will be used to override any of the same properties in effect for the transformation.
Throws: IllegalArgumentException if any of the argument keys are not recognized and are not namespace qualified.
See Also: javax.xml.transform.OutputKeys java.util.Properties
The recognized standard output properties are:
For example:
tran.setOutputProperty("standalone", "yes");
In the case of the cdata-section-elements property, the value should be a whitespace separated list of element names. The element name is the local name of the element, if it is in no namespace, or, the URI in braces followed immediately by the local name if the element is in that namespace. For example:
tran.setOutputProperty( "cdata-section-elements", "elem1 {http://example.uri}elem2 elem3");
The recognized Xalan extension elements are:
These must be in the extension namespace of "http://xml.apache.org/xalan". This is accomplished by putting the namespace URI in braces before the property name, for example:
tran.setOutputProperty( "{http://xml.apache.org/xalan}line-separator" , "\n");
Parameters: name The property name. value The requested value for the property.
Throws: IllegalArgumentException if the property name is not legal.
Parameters: 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.
Parameters: 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.
TransformerImpl
.
%REVIEW% Obsolete now that source_location is handled in the TransformerFactory?
Parameters: property a String
value value an Object
value
Parameters: b true if conflict warnings should be suppressed.
Parameters: limit A number that represents the limit of recursion, or -1 if no checking is to be done.
Parameters: doc A non-null reference to the root of the tree to be transformed.
Parameters: stylesheetRoot A non-null StylesheetRoot object, or null if you wish to clear the stylesheet reference.
Parameters: t The transform thread, may be null.
UNKNOWN: internal
Parameters: resolver An object that implements the URIResolver interface, or null.
Parameters: source The input source for the source tree.
Parameters: xcontext A non-null reference to the XPathContext associated with this transformer.
UNKNOWN: internal
Parameters: source The input for the source tree.
Throws: TransformerException
Parameters: source The input for the source tree. shouldRelease Flag indicating whether to release DTMManager.
Throws: TransformerException
Parameters: xmlSource The input for the source tree. outputTarget The output source target.
Throws: TransformerException
Parameters: xmlSource The input for the source tree. outputTarget The output source target. shouldRelease Flag indicating whether to release DTMManager.
Throws: TransformerException
Parameters: node The input source node, which can be any valid DTM node. outputTarget The output source target.
Throws: TransformerException
Parameters: node The input source node, which can be any valid DTM node.
Throws: TransformerException
Parameters: templateParent The template element that holds the fragment.
Returns: the NodeHandle for the root node of the resulting RTF.
Throws: TransformerException
UNKNOWN: advanced
Parameters: templateParent The template element that holds the fragment.
Returns: the NodeHandle for the root node of the resulting RTF.
Throws: TransformerException
UNKNOWN: advanced
Parameters: elem The parent element whose children will be output as a string.
Returns: The stringized result of executing the elements children.
Throws: TransformerException
UNKNOWN: advanced
Throws: SAXException