|
BEA Systems, Inc. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.xml.transform.Transformer | +--weblogic.apache.xalan.transformer.TransformerImpl
This class implements the
Transformer
interface, and is the core
representation of the transformation execution.
This class is based on an implementation from the Apache XML Project. In future releases the XML parser, XSLT processor, and associated classes will likely be updated to be based on a later version of the Apache implementations. Since Apache does not guarantee backwards compatibility between versions of their software, we cannot guarantee backwards compatibility of any of the classes contained in the weblogic.apache package or sub-packages.
Field Summary | |
static boolean |
S_DEBUG
This is a compile-time flag to turn off calling of trace listeners. |
Constructor Summary | |
TransformerImpl(StylesheetRoot stylesheet)
Construct a TransformerImpl. |
Method Summary | |
boolean |
applyTemplateToNode(ElemTemplateElement xslInstruction,
ElemTemplateElement template,
org.w3c.dom.Node child,
QName mode)
Given an element and mode, find the corresponding template and process the contents. |
void |
clearParameters()
Reset the parameters to a null list. |
org.xml.sax.ContentHandler |
createResultContentHandler(javax.xml.transform.Result outputTarget)
Create a result ContentHandler from a Result object, based on the current OutputProperties. |
org.xml.sax.ContentHandler |
createResultContentHandler(javax.xml.transform.Result outputTarget,
OutputProperties format)
Create a ContentHandler from a Result object and an OutputProperties. |
java.lang.Thread |
createTransformThread()
Create a thread for the transform. |
boolean |
currentTemplateRuleIsNull()
Tell if the current template rule is null, i.e. |
void |
executeChildTemplates(ElemTemplateElement elem,
org.w3c.dom.Node sourceNode,
QName mode,
boolean shouldAddAttrs)
Execute each of the children of a template element. |
void |
executeChildTemplates(ElemTemplateElement elem,
org.w3c.dom.Node sourceNode,
QName mode,
org.xml.sax.ContentHandler handler)
Execute each of the children of a template element. |
java.lang.String |
getBaseURLOfSource()
Get the base URL of the source. |
org.xml.sax.ContentHandler |
getContentHandler()
Get the content event handler. |
org.w3c.dom.traversal.NodeIterator |
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. |
org.w3c.dom.Node |
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. |
javax.xml.transform.ErrorListener |
getErrorListener()
Get the current error event handler. |
java.lang.Exception |
getExceptionThrown()
Get the exception thrown by the secondary thread (normally the transform thread). |
boolean |
getFeature(java.lang.String name)
Look up the value of a feature. |
org.xml.sax.ContentHandler |
getInputContentHandler()
Get a SAX2 ContentHandler for the input. |
org.xml.sax.ContentHandler |
getInputContentHandler(boolean doDocFrag)
Get a SAX2 ContentHandler for the input. |
org.xml.sax.ext.DeclHandler |
getInputDeclHandler()
Get a SAX2 DeclHandler for the input. |
org.xml.sax.ext.LexicalHandler |
getInputLexicalHandler()
Get a SAX2 LexicalHandler for the input. |
KeyManager |
getKeyManager()
Get the KeyManager object. |
org.w3c.dom.Node |
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. |
MsgMgr |
getMsgMgr()
Return the message manager. |
OutputProperties |
getOutputFormat()
Get the output properties used for the transformation. |
java.util.Properties |
getOutputProperties()
Get a copy of the output properties for the transformation. |
java.lang.String |
getOutputProperty(java.lang.String qnameString)
Get an output property that is in effect for the transformation. |
java.lang.String |
getOutputPropertyNoDefault(java.lang.String qnameString)
Get the value of a property, without using the default properties. |
javax.xml.transform.Result |
getOutputTarget()
Get the original output target. |
java.lang.Object |
getParameter(java.lang.String name)
Get a parameter that was explicitly set with setParameter or setParameters. |
boolean |
getQuietConflictWarnings()
Get quietConflictWarnings property. |
int |
getRecursionLimit()
Get the recursion limit. |
ResultTreeHandler |
getResultTreeHandler()
Get the ResultTreeHandler object. |
Serializer |
getSerializer()
Get the current serializer in use, which may well not be the main serializer (for instance, this may well be a text serializer for string creation from templates). |
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. |
TraceManager |
getTraceManager()
Get an instance of the trace manager for this transformation. |
javax.xml.transform.Transformer |
getTransformer()
Get the TrAX Transformer object in effect. |
java.lang.Thread |
getTransformThread()
Get the thread that the transform process is on. |
javax.xml.transform.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 |
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. |
org.w3c.dom.Node |
parseToNode(javax.xml.transform.Source source)
Process the an input source to a DOM node. |
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. |
java.util.Vector |
processSortKeys(ElemForEach foreach,
org.w3c.dom.Node sourceNodeContext)
Get the keys for the xsl:sort elements. |
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. |
protected void |
pushGlobalVars(org.w3c.dom.Node contextNode)
Internal -- push the global variables from the Stylesheet onto the context's runtime variable stack. |
void |
pushPairCurrentMatched(ElemTemplateElement template,
org.w3c.dom.Node child)
Push both the current xsl:template or xsl:for-each onto the stack, along with the child node that was matched. |
void |
pushParams(XPathContext xctxt,
ElemCallTemplate xslCallTemplateElement,
org.w3c.dom.Node sourceNode,
QName mode)
Given a template, search for the arguments and push them on the stack. |
void |
reset()
Reset the state. |
void |
run()
Run the transform thread. |
void |
setBaseURLOfSource(java.lang.String base)
Get the base URL of the source. |
void |
setContentHandler(org.xml.sax.ContentHandler handler)
Set the content event handler. |
void |
setCurrentElement(ElemTemplateElement e)
Set the top of the current template elements stack. |
void |
setErrorListener(javax.xml.transform.ErrorListener listener)
Set the error event listener. |
void |
setOutputFormat(OutputProperties oformat)
Set the output properties for the transformation. |
void |
setOutputProperties(java.util.Properties oformat)
Set the output properties for the transformation. |
void |
setOutputProperty(java.lang.String name,
java.lang.String value)
Set the value of a property. |
void |
setOutputTarget(javax.xml.transform.Result outputTarget)
Set the original output target. |
void |
setParameter(java.lang.String name,
java.lang.Object value)
Set a parameter for the transformation. |
void |
setParameter(java.lang.String name,
java.lang.String namespace,
java.lang.Object value)
Set a parameter for the templates. |
void |
setParameters(java.util.Properties params)
Set a bag of parameters for the transformation. |
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)
Get the recursion limit. |
void |
setSerializer(Serializer s)
Set the current serializer. |
void |
setSourceTreeDocForThread(org.w3c.dom.Node doc)
This is just a way to set the document for run(). |
void |
setStylesheet(StylesheetRoot stylesheetRoot)
Set the stylesheet for this processor. |
void |
setTransformThread(java.lang.Thread t)
Get the thread that the transform process is on. |
void |
setURIResolver(javax.xml.transform.URIResolver resolver)
Set an object that will be used to resolve URIs used in document(), etc. |
void |
setXPathContext(XPathContext xcontext)
Set the execution context for XPath. |
void |
transform(javax.xml.transform.Source source)
Process the source tree to SAX parse events. |
void |
transform(javax.xml.transform.Source xmlSource,
javax.xml.transform.Result outputTarget)
Process the source tree to the output result. |
void |
transformNode(org.w3c.dom.Node node)
Process the source node to the output result, if the processor supports the "http://xml.org/trax/features/dom/input" feature. |
void |
transformNode(org.w3c.dom.Node node,
javax.xml.transform.Result outputTarget)
Process the source node to the output result, if the processor supports the "http://xml.org/trax/features/dom/input" feature. |
org.w3c.dom.DocumentFragment |
transformToRTF(ElemTemplateElement templateParent,
org.w3c.dom.Node sourceNode,
QName mode)
Given a stylesheet element, create a result tree fragment from it's contents. |
java.lang.String |
transformToString(ElemTemplateElement elem,
org.w3c.dom.Node sourceNode,
QName mode)
Take the contents of a template element, process it, and convert it to a string. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static boolean S_DEBUG
Constructor Detail |
public TransformerImpl(StylesheetRoot stylesheet)
stylesheet
- The root of the stylesheet tree.Method Detail |
public void reset()
public boolean isParserEventsOnMain()
public java.lang.Thread getTransformThread()
public void setTransformThread(java.lang.Thread t)
t
- The transform thread, may be null.public void transform(javax.xml.transform.Source source) throws javax.xml.transform.TransformerException
source
- The input for the source tree.public java.lang.String getBaseURLOfSource()
public void setBaseURLOfSource(java.lang.String base)
public javax.xml.transform.Result getOutputTarget()
public void setOutputTarget(javax.xml.transform.Result outputTarget)
public java.lang.String getOutputProperty(java.lang.String qnameString) throws java.lang.IllegalArgumentException
name
- A non-null String that specifies an output
property name, which may be namespace qualified.OutputKeys
public java.lang.String getOutputPropertyNoDefault(java.lang.String qnameString) throws java.lang.IllegalArgumentException
name
- The property name, which is a fully-qualified URI.public void setOutputProperty(java.lang.String name, java.lang.String value) throws java.lang.IllegalArgumentException
"http://xml.apache.org/xslt/sourcebase" - the base URL for the source, which is needed when pure SAX ContentHandler transformation is to be done.
name
- The property name, which is a fully-qualified URI.value
- The requested value for the property.public void setOutputProperties(java.util.Properties oformat)
If argument to this function is null, any properties previously set will be removed.
oformat
- A set of output properties that will be
used to override any of the same properties in effect
for the transformation.public java.util.Properties getOutputProperties()
Note that mutation of the Properties object returned will not effect the properties that the transformation contains.
public org.w3c.dom.Node parseToNode(javax.xml.transform.Source source) throws javax.xml.transform.TransformerException
xmlSource
- The input for the source tree.public org.xml.sax.ContentHandler createResultContentHandler(javax.xml.transform.Result outputTarget) throws javax.xml.transform.TransformerException
outputTarget
- Where the transform result should go,
should not be null.public org.xml.sax.ContentHandler createResultContentHandler(javax.xml.transform.Result outputTarget, OutputProperties format) throws javax.xml.transform.TransformerException
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.public void transform(javax.xml.transform.Source xmlSource, javax.xml.transform.Result outputTarget) throws javax.xml.transform.TransformerException
xmlSource
- The input for the source tree.outputTarget
- The output source target.public void transformNode(org.w3c.dom.Node node, javax.xml.transform.Result outputTarget) throws javax.xml.transform.TransformerException
node
- The input source node, which can be any valid DOM node.outputTarget
- The output source target.public void transformNode(org.w3c.dom.Node node) throws javax.xml.transform.TransformerException
node
- The input source node, which can be any valid DOM node.outputTarget
- The output source target.public org.xml.sax.ContentHandler getInputContentHandler()
public org.xml.sax.ContentHandler getInputContentHandler(boolean doDocFrag)
doDocFrag
- true if a DocumentFragment should be created as
the root, rather than a Document.public org.xml.sax.ext.DeclHandler getInputDeclHandler()
public org.xml.sax.ext.LexicalHandler getInputLexicalHandler()
public void setOutputFormat(OutputProperties oformat)
oformat
- A valid OutputProperties object (which will
not be mutated), or null.public OutputProperties getOutputFormat()
public Serializer getSerializer()
public void setSerializer(Serializer s)
s
- The current serializer, or null.public void setParameter(java.lang.String name, java.lang.String namespace, java.lang.Object value)
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.public void setParameter(java.lang.String name, java.lang.Object value)
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.public java.lang.Object getParameter(java.lang.String name)
public void setParameters(java.util.Properties params)
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.public void clearParameters()
public void pushParams(XPathContext xctxt, ElemCallTemplate xslCallTemplateElement, org.w3c.dom.Node sourceNode, QName mode) throws javax.xml.transform.TransformerException
xctxt
- The XPath runtime state for this transformation.xslCallTemplateElement
- The xsl:call-template element.sourceNode
- The Current source tree node.mode
- The current xslt mode.protected void pushGlobalVars(org.w3c.dom.Node contextNode) throws javax.xml.transform.TransformerException
If we encounter a variable that is already defined in the variable stack, we ignore it. This is because the second variable definition will be at a lower import precedence. Presumably, global variables at the same import precedence with the same name will have been caught during the recompose process.
However, if we encounter a parameter that is already defined in the variable stack, we need to see if this is a parameter whose value was supplied by a setParameter call. If so, we need to "receive" the one already in the stack, ignoring this one. If it is just an earlier xsl:param or xsl:variable definition, we ignore it using the same reasoning as explained above for the variable.
contextNode
- The root of the source tree, can't be null.public void setURIResolver(javax.xml.transform.URIResolver resolver)
resolver
- An object that implements the URIResolver interface,
or null.public javax.xml.transform.URIResolver getURIResolver()
public void setContentHandler(org.xml.sax.ContentHandler handler)
resolver
- The new content handler.XMLReader.setContentHandler(org.xml.sax.ContentHandler)
public org.xml.sax.ContentHandler getContentHandler()
XMLReader.getContentHandler()
public org.w3c.dom.DocumentFragment transformToRTF(ElemTemplateElement templateParent, org.w3c.dom.Node sourceNode, QName mode) throws javax.xml.transform.TransformerException
templateParent
- The template element that holds the fragment.sourceNode
- The current source context node.mode
- The mode under which the template is operating.public ObjectPool getStringWriterPool()
public java.lang.String transformToString(ElemTemplateElement elem, org.w3c.dom.Node sourceNode, QName mode) throws javax.xml.transform.TransformerException
elem
- The parent element whose children will be output
as a string.transformer
- The XSLT transformer instance.sourceNode
- The current source node context.mode
- The current xslt mode.public boolean applyTemplateToNode(ElemTemplateElement xslInstruction, ElemTemplateElement template, org.w3c.dom.Node child, QName mode) throws javax.xml.transform.TransformerException
xslInstruction
- The calling element.template
- The template to use if xsl:for-each, or null.child
- The source context node.mode
- The current mode, may be null.public void executeChildTemplates(ElemTemplateElement elem, org.w3c.dom.Node sourceNode, QName mode, org.xml.sax.ContentHandler handler) throws javax.xml.transform.TransformerException
elem
- The ElemTemplateElement that contains the children
that should execute.sourceNode
- The current context node.mode
- The current mode.handler
- The ContentHandler to where the result events
should be fed.public void executeChildTemplates(ElemTemplateElement elem, org.w3c.dom.Node sourceNode, QName mode, boolean shouldAddAttrs) throws javax.xml.transform.TransformerException
transformer
- The XSLT transformer instance.elem
- The ElemTemplateElement that contains the children
that should execute.sourceNode
- The current context node.mode
- The current mode.shouldAddAttrs
- true if xsl:attributes should be executed.public java.util.Vector processSortKeys(ElemForEach foreach, org.w3c.dom.Node sourceNodeContext) throws javax.xml.transform.TransformerException
foreach
- Valid ElemForEach element, not null.sourceNodeContext
- The current node context in the source tree,
needed to evaluate the Attribute Value Templates.public void pushElemTemplateElement(ElemTemplateElement elem)
elem
- The current ElemTemplateElement (may be null, and then
set via setCurrentElement).public void popElemTemplateElement()
public void setCurrentElement(ElemTemplateElement e)
e
- The current ElemTemplateElement about to
be executed.public ElemTemplateElement getCurrentElement()
public org.w3c.dom.Node getCurrentNode()
public ElemTemplate getCurrentTemplate()
Please note that the ElemTemplate returned may be a default template, and thus may not have a template defined in the stylesheet.
public void pushPairCurrentMatched(ElemTemplateElement template, org.w3c.dom.Node child)
template
- xsl:template or xsl:for-each.child
- The child that was matched.public void popCurrentMatched()
public ElemTemplate getMatchedTemplate()
public org.w3c.dom.Node getMatchedNode()
public org.w3c.dom.traversal.NodeIterator getContextNodeList()
public javax.xml.transform.Transformer getTransformer()
public void setStylesheet(StylesheetRoot stylesheetRoot)
stylesheetRoot
- A non-null StylesheetRoot object,
or null if you wish to clear the stylesheet reference.public StylesheetRoot getStylesheet()
public boolean getQuietConflictWarnings()
public void setQuietConflictWarnings(boolean b)
b
- true if conflict warnings should be suppressed.public void setXPathContext(XPathContext xcontext)
xcontext
- A non-null reference to the XPathContext
associated with this transformer.public XPathContext getXPathContext()
public StackGuard getStackGuard()
public int getRecursionLimit()
public void setRecursionLimit(int limit)
limit
- A number that represents the limit of recursion,
or -1 if no checking is to be done.public ResultTreeHandler getResultTreeHandler()
public KeyManager getKeyManager()
public boolean isRecursiveAttrSet(ElemAttributeSet attrSet)
attrSet
- A non-null ElemAttributeSet reference.public void pushElemAttributeSet(ElemAttributeSet attrSet)
attrSet
- A non-null ElemAttributeSet reference.public void popElemAttributeSet()
public CountersTable getCountersTable()
public boolean currentTemplateRuleIsNull()
public void pushCurrentTemplateRuleIsNull(boolean b)
b
- True if the we are executing an xsl:for-each
(or xsl:call-template?).public void popCurrentTemplateRuleIsNull()
public MsgMgr getMsgMgr()
public void setErrorListener(javax.xml.transform.ErrorListener listener) throws java.lang.IllegalArgumentException
listener
- The new error listener.public javax.xml.transform.ErrorListener getErrorListener()
public TraceManager getTraceManager()
public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
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.
name
- The feature name, which is a fully-qualified
URI.public java.lang.Thread createTransformThread()
public java.lang.Exception getExceptionThrown()
public void setSourceTreeDocForThread(org.w3c.dom.Node doc)
doc
- A non-null reference to the root of the
tree to be transformed.public boolean isTransformDone()
public void run()
|
Documentation is available at http://download.oracle.com/docs/cd/E13222_01/wls/docs61 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |