Using XSL I'm trying to transform this XML:
<book><title>This is a <b>great</b> book</title></book>
in this xml:
<book>This is a <bold>great</bold> book</book>
using this xsl:
<xsl:for-each select="book/title/*">
<xsl:choose>
<xsl:when test="name() = 'b'">
<bold>
<xsl:value-of select="text()"/>
</bold>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="text()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
but my conclusion is as follows:
<book><bold>great</bold></bold>
Can someone explain why the root text <title>is lost? I believe that my request for each request may need to be changed, but I cannot understand what should be.
Keep in mind that I cannot use <xsl:template match>due to the complexity of my stylesheet.
Thanks!
source
share