[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Passing document fragments as nodsets

Subject: Re: Passing document fragments as nodsets
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 7 Jul 2003 10:03:01 +0100
xsl xalan nodeset
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.