I have this soap request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<soapenv:Header>
<wsse:Security mustUnderstand="1">
<wsse:UsernameToken>
<wsse:Username>test</wsse:Username>
<wsse:Password>test</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<hel:docTypeRef_tns_sayHello xmlns:hel="http://aaa/bbb.fr">
<arg0>John</arg0>
<arg1>111-222-333</arg1>
</hel:docTypeRef_tns_sayHello>
</soapenv:Body>
</soapenv:Envelope>
I would like first to change the namespace uri appearing in the hel:docTypeRef_tns_sayHello element to something else (ex : http://test.fr). This namespace definition can appear in the hel:docTypeRef_tns_sayHello element as in the code above or in the root Envelope element, so i'd like to add this namespace definition only in the Envelope element
Then I'd like to modify the value of mustUnderstand attribute to 0.
The result should be of the form :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext- 1.0.xsd"
**xmlns:hel="http://test.fr"**>
<soapenv:Header>
<wsse:Security mustUnderstand="**0**">
<wsse:UsernameToken>
<wsse:Username>test</wsse:Username>
<wsse:Password>test</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<hel:docTypeRef_tns_sayHello>
<arg0>John</arg0>
<arg1>111-222-333</arg1>
</hel:docTypeRef_tns_sayHello>
</soapenv:Body>
</soapenv:Envelope>
Could somebody help me ? Thancks !
I. Here is a generic, parameterized XSLT 1.0 solution:
when this transformation is applied on the provided XML document:
the wanted, correct result is produced:
Do note: In XSLT 1.0 it isn't possible without using an extension function (at least
xxx:node-set()
)to dynamically add a new namespace (that doesn't exist already as a namespace node) to an element. In XSLT 2.0 the newxsl:namespace
instruction can be used to dynamically construct a new namespace node from dynamic (statically unknown) parts.Here is a small example how with XSLT 1.0 to add a new, non-existent at the start of the transformation namespace node:
when this transformation is applied on this XML document:
it re-creates the top element
t
with all its namespace nodes and adds one new namespace node to it:II. Here is a full, XSLT 2.0 solution:
When this transformation is applied on the same XML document (above), the wanted, correct result is produced: