Reputation: 3
I want to transform xml to another xml with few conditions. One of condition is whenever my xml element has DC19DAKHN
or DC19D0000
, in transformed xml I would like to override them with value MN019015J
.
How do I do this in XSLT?
My XML Code
<MyID>DC19DAKHN</MyID>
My xslt output is
<myID>DC19D0000</myID>
I want this to look like this instead
<myID>MN019015J</myID>
Do I use If Choose?
Upvotes: 0
Views: 512
Reputation: 915
Try this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="MyID/text()[.='DC19DAKHN']">MN019015J</xsl:template>
<xsl:template match="myID/text()[.='DC19D0000']">MN019015J</xsl:template>
</xsl:stylesheet>
Upvotes: 1