xml - Why are some of the child values being skipped? -
i have values in xml file being skipped.. basically, want list every value in "abrev" tag in 1 column, , in column respective "forme" attribute value. elements in both columns must distincts.
try way:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="yes"/> <xsl:strip-space elements="*"/> <xsl:key name="formes" match="abrev" use="@forme"/> <xsl:key name="values" match="abrev" use="concat(@forme, '|', normalize-space(.))"/> <xsl:template match="/"> <html> <table> <xsl:for-each select="//abrev[generate-id(.)=generate-id(key('formes',@forme))]"> <tr> <td> <xsl:value-of select="@forme"/> </td> <td> <xsl:apply-templates select="key('formes',@forme)[generate-id(.)=generate-id(key('values',concat(@forme, '|', normalize-space(.))))]"/> </td> </tr> </xsl:for-each> </table> </html> </xsl:template> <xsl:template match="abrev"> <xsl:if test="position() != 1">, </xsl:if> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>
btw, how difficult minimize example to:
<collection> <abrev forme="mais">ms</abrev> <abrev forme="mais">ms</abrev> </collection>
Comments
Post a Comment