xml - How to compare the value of the current for-each element? -
xml:
<a>1</a> <a>2</a> <b>3</b> <a>4</a> <b>5</b>
desired output:
value value value b value value b
xslt:
<xsl:for-each select="a | b"> <xsl:if test="? = 'a'"> value </xsl:if> <xsl:if test="? = 'b'"> value b </xsl:if> </xsl:for-each>
how compare value of current element in line <xsl:if test="? = 'a'">
, <xsl:if test="? = 'b'">
?
you need name()
, strange way of going it. posted, want output names of nodes. in case:
<xsl:apply-templates select='a|b' /> <xsl:template match='a|b'> value <xsl:value-of select='name()' /> </xsl:template>
Comments
Post a Comment