Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting nodes into a variable

Status
Not open for further replies.

spiel2001

Programmer
Nov 1, 2001
39
0
0
US
MrTom --

First, thank you for the tip.

I've been playing with it all morning and not getting anywhere. I see exactly how it is supposed to be working, and it makes perfect sense, but I am stuck on a runtime error "variable or parameter 'sorted' must evaluate to a node list"

I thought I would move this out of the original thread and see if we can play with it and come up with the solution.

Here's a code snipped for it which produces the error listed above on the <xsl:for-each select=&quot;$sorted/Item&quot;> statement. It would appear that $sorted is either a null set or is not evaluating to a node list at a minimum.

<Data>
<Item>
<Name value=&quot;R&quot;/>
<Attribute value=&quot;123&quot;/>
</Item>
<Item>
<Name value=&quot;D&quot;/>
<Attribute value=&quot;ABC&quot;/>
</Item>
<Item>
<Name value=&quot;X&quot;/>
<Attribute value=&quot;QRS&quot;/>
</Item>
<Item>
<Name value=&quot;A&quot;/>
<Attribute value=&quot;XSL&quot;/>
</Item>
</Data>

<xsl:template match=&quot;/&quot;>

<xsl:variable name=&quot;sorted&quot;>
<xsl:for-each select=&quot;Item&quot;>
<xsl:sort select=&quot;Name/@value&quot;/>
<xsl:copy-of select=&quot;.&quot;/>
</xsl:for-each>
</xsl:variable>

<xsl:for-each select=&quot;$sorted/Item&quot;>
<xsl:value-of select=&quot;Name/@value&quot;/> --
<xsl:value-of select=&quot;Attribute/@value&quot;/>
</xsl:for-each>

</xsl:template>

I've played with this for the last couple of hours and don't seem to be getting anywhere. Looks like the learning curve is still biting my butt.
 
MrTom -- thanks a million.

I'm still playing with it but can't seem to get past the $sorted not being a node list problem. Looked darn good on paper though ~grin~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top