Re: [xsl] node-set

Subject: Re: [xsl] node-set
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Sun, 01 Jul 2001 18:09:52 GMT
Jason,

>Hello everyone,
>Im having problems selecting a nodeset with the node-set() in msxml3.  Im
>not getting an "Reference to variable or parameter must evaluate to a node
>list" error but It doesnt seem to select the node. Working xml/xsl below.
>
Looking at the SDK documentation I can see why you are confused.  You
are not the first, and probably not the last!

node-set is supposed to have a result tree fragment as argument, in
other words a variable that has been set using xsl:variable with a
template body instead of a select statement.

You seem to have misread the spec to mean it can take a string
variable containing an XPath expression and return the node-set
obtained by interpreting it.  Sorry, it doesn't.  Some processors do
have such a function (not called node-set) but I do not think MSXML is
one of them.

However, it looks like you do not need a general XPath expression.
Instead of
>			<xsl:variable name="peerFullPath"
>select="concat($peerPath,'/',$quarterYear)" />
><td><xsl:value-of select="msxsl:node-set($peerFullPath)/peer1" /></td>

Try
<td><xsl:value-of
select="*[local-name()=$peerPath]/*[local-name()=$quarterYear]/peer1"
/></td>

Your parameters must now be element names: this is true in your
example, but you may have simplified things for the purpose of posting
to the list.
(Watch out if your input document uses name spaces)

If you are doing the design of the XML too, think again: generally you
should not encode information in element names, e.g. instead of
<comparePe>, <compareESP> you should perhaps have
<compare type="Pe">, <compare type="ESP">.  More typing, but you will
find processing the document easier, and the whole thing will be
easier to maintain.

Regards,
Trevor Nash

--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread