Hi,
I have an xml input (wsse) and I want to change the value of one of the attribute "mustUnderstand" while copying.
Input.xml
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:env = "http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<wsse:Security env:mustUnderstand = "1" xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">user</wsse:Username>
<wsse:Password xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<ns0:addDispute xmlns:ns0 = "http://www.openuri.org/">
<xmlString xsi:type = "def:string" xmlns:def = "http://www.w3.org/2001/XMLSchema"></xmlString>
</ns0:addDispute>
</env:Body>
</env:Envelope>
Stylesheet
<?xml version="1.0" encoding="windows-1252" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<!-- Root template -->
<!-- "env:Envelope/env:Header/wsse:Security/@env:mustUnderstand" -->
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="env:Envelope">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="env:Header">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="env:Body">
<xsl:copy-of select="." />
</xsl:template>
<xsl:template match="wsse:Security">
<xsl:copy>
<xsl:attribute name="env:mustUnderstand">0</xsl:attribute>
</xsl:copy>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="wsse:UsernameToken">
<xsl:copy>
<xsl:copy-of select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I'm getting output
<?xml version="1.0" encoding="UTF-16"?>
<env:Envelope
xmlns:env = "http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<wsse:Security env:mustUnderstand = "0" xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"/>
<wsse:UsernameToken xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:Username>wlisap</wsse:Username>
<wsse:Password>saptest1</wsse:Password>
</wsse:UsernameToken>
</env:Header>
<env:Body>
<ns0:addDispute xmlns:ns0 = "http://www.openuri.org/">
<xmlString xsi:type = "def:string" xmlns:def = "http://www.w3.org/2001/XMLSchema"></xmlString>
</ns0:addDispute>
</env:Body>
</env:Envelope>
As you can see in the section "wsse:Username" and "wsse:Password" I do not get the xmlns attributes.
Basically I want the complete Input as is and just change "env:mustUnderstand" from "1" to "0".
Thanks for the help in advance