Reputation:
I have the following student xml doc. Is it possible to replace the value true with value DELETED in the output?
xml doc code
<Student>
<Deleted>true</Deleted>
</Student>
xslt code
<Student>
<xsl:choose>
<xsl:when test="Deleted='true'">
<xsl:value-of select="Deleted"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="PRESENT"/>
</xsl:otherwise>
</xsl:choose>
</Student>
I would like output to be
<Student>
<StudentDeleted>DELETED</StudentDeleted>
</Student>
The following is what I am getting as output which is not what I want
<Student>
<StudentDeleted>true</StudentDeleted>
</Student>
Upvotes: 0
Views: 38
Reputation: 67
<?xml version="1.0" encoding="UTF-8"?>
<xsl:template match="Student">
<Student>
<xsl:choose>
<xsl:when test="child::Deleted/text()='true'">
<StudentDeleted>
<xsl:value-of select="'Deleted'"/>
</StudentDeleted>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="PRESENT"/>
</xsl:otherwise>
</xsl:choose>
</Student>
</xsl:template>
Upvotes: 1