Altova Mailing List Archives


Re: [xsl] Passing document fragments as nodsets

From: Jeni Tennison <jeni@---------------->
To:
Date: 7/7/2003 1:03:00 AM
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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.