Re: Applying a transform to a tranform
It is possible in XSLT 1.0 only if you use your vendor's node-set() extension, which is designed specifically for this purpose. Most processors have this extension function available in some form: check your documentation. In particular, you might look into whether yours supports functions in the EXSLT namespace ("Extended XSLT", an effort of several well-regarded members of our community, see http://exslt.org), which is even a semi-portable version.
In XSLT 2.0 the conversion of result-tree-fragment to node-set, which is what this function does, is transparent: you won't even have to think about it.
To do what you want to do using the EXSLT version:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" extension-element-prefixes="exslt">
<xsl:variable name="first-process-results"> <!-- you'll want either an explicit path here, or better, a mode, to avoid infinite recursion --> <xsl:apply-templates select="/rowset" mode="first"/> </xsl:variable>
... then your normal templates in the mode "first" ...
And then your actual transform:
<xsl:template match="/"> <xsl:apply-templates select="exslt:node-set($first-process-results)" mode="second"/> </xsl:template>
... and your second-pass templates in the mode "second"....
Basically what this is doing is processing the document in one mode, binding the result to a variable (in XSLT 1.0 it's a "result tree fragment"), then the stylesheet processes this fragment, turning it into a node set using the extension function.
You don't have to use modes, but you might be sorry if you try it without. :->
At 05:04 PM 9/9/2003, you wrote:
I thought the following logic would work but it doesn't
In the context where you invoke these, the second apply-templates has no way to know you don't mean "child::tree" (XPath "tree" = XPath "child::tree"), but rather the results of the first apply-templates. It's only doing what you're telling it to (processing the tree children of the context node).
It appears as though this is transforming the original doc in both instances (i.e. the rowset template select doesn't "pass" the results of its transform forward).
No, and it'd be pretty bizarre if it did, without your even asking. (Where would it all end? :-> )
Anyhow, try a node-set() function and see how it works.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format