|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Passing document fragments as nodsets
Hi Simon,
> I'm having a bit of a struggle with passing a subset of nodes around
> in a xsl file. I have extracted a set of nodes that follow a XPath
> rule where an attribute is set, and am paaaing this a a parameter to
> a template.
>
> <xsl:with-param name="image-nodes">
> <xsl:value-of select="xalan:nodeset(.)/image[@position = 'left']" />
> </xsl:with-param>
When you use the content of a variable-binding element
(<xsl:variable>, <xsl:param> or <xsl:with-param>), the result is a
result tree fragment -- a small tree that you can't further process.
If you want to set a variable/parameter to existing nodes (or to
simple values like numbers and strings) then you should use the select
attribute instead:
<xsl:with-param name="image-nodes"
select="xalan:nodeset(.)/image[@position = 'left']" />
By the way, I doubt that xalan:nodeset(.) is doing anything for you
here, since it's used to convert result tree fragments to node sets,
but the context node (.) cannot be a result tree fragment. I think
that just:
<xsl:with-param name="image-nodes"
select="image[@position = 'left']" />
will do what you want.
A quick scan through your stylesheet shows that you're using the
content of the variable-binding elements quite a lot when you should
be using the select attribute instead.
By the way, the latest version of Xalan supports exsl:node-set(),
which will work with other processors as well, so for portability it's
better to use exsl:node-set() than xalan:nodeset().
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
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
|

Cart








