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