Sign In/My Account | View Cart  
advertisement

Article:
 Understanding the node-set() Function
Subject: Strange retro article on node-set
Date: 2003-07-21 04:16:03
From: Jirka Kosek
Response to: Strange retro article on node-set

If by "strange retro" you mean that node-set() function is well known and its usage obvious, that's true at least for me and you. But many times I met people who are doing XSLT and who can't solve some problems because they are unaware of nodeset and result tree fragment differences. This article is targeted exactly for the later group of XSLT developers.

No Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Titles Only Full Threads Newest First
  • article on node-set
    2009-10-18 20:34:50 Nu2xXl@2009 [Reply]

    I'm trying to do a external lookup on multiple children of a node item/clrs/*, then sort the looked-up value, pick the min-value using the node-set. I have a sample xml data set and my code snippet to do that.. Obviously that is not working ... How could this be achieved... Please help..


    <items>
    <item att1="val1" att2="val2">
    <clrs>
    <clr id="clr1"/>
    <clr id="clr2"/>
    </clrs>
    <item>
    </items>


    code snippet:


    <xsl:template name="minclr">


    <xsl:variable name="allclrs" select="Item/Clrs/Clr"/>


    <xsl:variable name="allclrnames" >


    <xsl:for-each select="$allclrs">
    <xsl:variable name="locclrid" select="current()"/>
    <xsl:for-each select="$clrextdoc">
    <xsl:sort select="key('extclrlu',$locclrid)/@clrname" data-type="text" order="ascending"/>
    <xsl:element name="extclrname"><xsl:value-of select="key('extclrlu',$locclrid)/@clrname" /></xsl:element>
    </xsl:for-each>
    </xsl:for-each>


    </xsl:variable>


    <xsl:variable name="clrnamenodes" select="msxml:node-set($allclrnames)"/>
    <xsl:for-each select="$clrnamenodes">
    <xsl:sort select="extclrname" data-type="text" order="ascending"/>
    <xsl:if test="position()=1">
    <xsl:value-of select="current()"/>
    </xsl:if>
    </xsl:for-each>


    </xsl:template>


  • Strange retro article on node-set
    2003-07-21 17:41:53 James Fuller [Reply]

    apologies, my comment wasn't meant to be negative, its a good article lifting the mist of confusion re the need for node-sets in a world of RTF. It has got me thinking about nodesets again though....and why we ever had RTF.





Sponsored By: