xslt - Get value of an attribute, where you don't know the name -
say if have xml line such as:
<machine center="10" left="25" right="162" />
and, using xslt, want turn in like:
<measurement type="center">10</measurement> <measurement type="left">25</measurement> <measurement type="right">162</measurement>
how do that? @ moment have following, missing 1 crucial part:
<measurement> <xsl:for-each select="@"> <xsl:attribute name="type"> <xsl:value-of name="name()"> </xsl:attribute name="type"> <xsl:value-of name="[what_goes_here?]" /> </xsl:for-each> </measurement>
try way;
<xsl:template match="machine"> <xsl:for-each select="@*"> <measurement type="{name()}"> <xsl:value-of select="." /> </measurement> </xsl:for-each> </xsl:template>
Comments
Post a Comment