[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: How do I build a nodeset "programmatically" for p
Subject: Re: How do I build a nodeset "programmatically" for passing to another template?|
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 17 Aug 2006 11:47:53 -0400
What you're trying to do is a useful and very powerful technique,
only unfortunately disallowed by a restriction in classical XSLT 1.0,
which defines a variable bound dynamically in such a way as a result
tree fragment (RTF), which by definition may not be processed
further. (An RTF may only be copied to the result tree or converted
to a string, which is somewhat useful but not as much as one would like.)
Because this restriction was considered by some to be rather
artificial, and the technique so useful, it was removed in XSLT 2.0,
where what you are doing will work transparently.
In a conformant XSLT 1.0 processor, you will get an error when you
try this, typically along the lines of "cannot process Result Tree
Fragment". To get around this, many XSLT 1.0 processors provide an
extension function. For example, a function node-set() is available,
in many processors, in the EXSLT namespace (see www.exslt.org), which
you could use, as in node-set($speed_table_values), to get up and running.
I believe the node-set() extension function may also be available
natively in an XSLT 1.1 processor, but since the 1.1 specification
was shelved before making Recommendation status, YYMV.
FWIW, some of us are calling this technique "micropipelining", as it
entails creating a tree fragment and then processing it. Not only is
it very powerful, it's very much in the XSLT 2.0 spirit of things,
and at the core of any number of advanced methodologies such as
At 11:34 AM 8/17/2006, you wrote:
I'm using Saxon 6.5.x (and XSL 1.1).
Searches on the web and this list's archives give me tantalizing hints
that what I want to do is theoretically possible. All of the examples I
find seem to be "reducers" (e.g. sum a set of numbers spread throughout
a nodeset, or combine nodes into a single string), rather than
My stylesheets are pull style that build XSL-FO output for further
processing by Apache-FOP. What I'm trying to do is build a nodeset in a
variable so that I can rely on some generic fo:table templates to
produce the output rather than custom templates for each occurrence.
Due to limits of what is currently in the XML input files, I'm forced to
do some calculation/nodeset building to supplement the structure already
in the XML file.
Is it possible for a chunk of XSL like:
select="/vdt:report/vdt:run_metrics/*[normalize-space(text()) = 'Avg
<xsl:variable name="ay_90pct" select="format-number(0.9 * $max_ay,
<xsl:with-param name="ay_target" select="$ay_90pct"/>
To result in the variable $speed_table_values looking something like ?:
(The numbers in the table are bogus but the nodeset structure is what
I'm interested in.)
I would then have a later <xsl:call-template> that contained
As you can see, this particular problem is mostly interating over nodes
provided within the XSL sheet itself rather than the source XML. Only
the first line of my example is grabbing a value/node from the source
tree. I need to accomplish this in a single pass (not multiple calls to
an XSLT transformer). Assuming what I want to do is possible in XSL
1.1, any links to similar examples would be much appreciated.
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