xml - XSLT Conditional Count -
new site. hoping can me figure out why code not working. used other posts on subject site close, can't see error.
xslt:
<!-- keyset based on subject (part number) --> <xsl:key name="key_partnumber" match="subject" use="."/> <xsl:template match="/"> <bom> <!-- each unique subject (part number) --> <xsl:for-each select="//markup/subject[generate-id() = generate-id(key('key_partnumber', .)[1])]"> <part> <xsl:attribute name="part_number"> <xsl:value-of select="."/> </xsl:attribute> <xsl:attribute name="count"> <xsl:value-of select="count(//markup[subject=.])"/> </xsl:attribute> </part> </xsl:for-each> </bom> </xsl:template> </xsl:stylesheet>
when run transform, counts of 0. below screenshot of both sample xml file, result of xpath query getting correct result. sample xml xpath result
replace [subject=.]
[subject=current()]
. context item changes within predicate.
Comments
Post a Comment