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 Titles Only Oldest First
  • 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.




  • 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>


    • article on node-set
      2009-10-19 04:13:20 Jirka Kosek [Reply]

      I haven't studied your code in detail, but first problem which has to be fixed is consistent usage of lower/upper-case in element names. Your XML elements are named like "clrs", but your XSLT code refers them as "Clrs".


      Anyway, for XSLT related questions it is best to ask at xsl-list mailing list.


Sponsored By: