I have an XML like this
<?xml version="1.0" encoding="UTF-8"?>
<OMDefault xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PrintDollarsAndCents>X</PrintDollarsAndCents>
<MailAddrLine1>Add1</MailAddrLine1>
<MailAddrLine2>Add2</MailAddrLine2>
</OMDefault>
I would like to have an XSLT to transform the XML to this
<?xml version="1.0" encoding="UTF-8"?>
<OMDefault xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PrintDollarsAndCents>Y</PrintDollarsAndCents>
<MailAddrLine1>Add1</MailAddrLine1>
<MailAddrLine2>Add2</MailAddrLine2>
</OMDefault>
Please notice the 'X' gets transformed to 'Y' if the attribute is PrintDollarsAndCents and its value is 'X' Could someone please help me with this? As I am very new to this XSLT thing.
Thank you in advance.
Basically you want an identity transform, with override rules.
The following transform
applied to your input, produces the result:
The first template is an identity transform, which copies the input document exactly.
The second template overrides text nodes with a value of
X
that are children of aPrintDollarsAndCents
template. Note that it emits the valueY
instead of its actual content.