Re: [xsl] [string to node]

Subject: Re: [xsl] [string to node]
From: Aditya Sakhuja <aditya.sakhuja@xxxxxxxxx>
Date: Sun, 21 Feb 2010 16:17:13 -0800
So, I have thought of <xsl:variable name="a" select="..."/> to get the
value. however, I have to choose depending upon certain conditions,
and hence the <xsl:choose> inside. Also, exsl:node-set() library is
not complete ( If you download this,
the node-set xsl is missing. I had looked at this option earlier.

However, I have just managed to get what I need working using the
inherent, xalan:nodeset() which comes bundled with the Xalan-C
With Xalan-C one can have a structure like this:

<xsl:stylesheet xmlns:xsl="";

<xsl:if test="count(xalan:nodeset($a)) &lt; 2 >



On Sun, Feb 21, 2010 at 3:13 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
> On 21/02/2010 23:06, Aditya Sakhuja wrote:
>> Hi,
>> Thanks for testing it out.
>> The inherent problem is that I get a string, and not a node-set,
> No. As stated in 2 previous replies, you get a result tree fragment rather
> than a node set, or string.
>> needed by count(). David, ultimately the value in the variable
>> obtained through value-of is not a node or a node set. Is there a way
>> you think, I can get the count() fetch me the number of 'dd' elements
>> using xalan-c processor ?
> in xslt 1 you can't directly query into a result tree fragment.
> You coud use exslt:nose-set() extension function to turn your result tree
> fragment into a node set (note if $a were a string you could not use
> exslt:node-set) however most likely you do not need to create the result
> tree fragment in the first place.
> If you use xsl:variable with select rather than with element content it
> binds the value selected rather than a result tree fragment with copies of
> the original nodes.
> <xsl;variable name="a" select="//dd"/>
> then B#a is a node set of dd nodes and count($a) will tell you how many dd
> there are in the set.
> David


-Cbib B%C%

Current Thread