Sign In/My Account | View Cart  
advertisement

Article:
 Understanding the node-set() Function
Subject: article on node-set
Date: 2009-10-18 20:34:50
From: Nu2xXl@2009
Response to: Strange retro article on node-set

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>


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


Titles Only Titles Only Newest First
  • article on node-set
    2009-10-19 04:13:20 Jirka Kosek

    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: