Subject: Re: [xsl] Passing document fragments as nodsets From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 7 Jul 2003 10:03:01 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Passing document fragment, David Carlisle | Thread | Re: [xsl] Passing document fragment, Simon Kelly |
[xsl] Binary to XML Translation, ela goyal | Date | Re: [xsl] Binary to XML Translation, Jeni Tennison |
Month |