Reputation: 35
I have below XMl:
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http:test/201/2"
xmlns:m0="http:test/201/3"
xmlns:ns0="http:test/201/4"
xmlns:ns2="http:test/201/5"
xmlns:ns1="http:test/201/6"
xmlns:ns3="http:test/201/7"
xmlns:ns6="http:test/201/8"
xmlns:ns4="http:test/201/9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<ns0:ResponseHeader>
<ns:Env>Dev</ns:Env>
<ns:Version>1</ns:Version>
<ns:Server></ns:Server>
<ns:Name>NAME</ns:Name>
</ns0:ResponseHeader>
</soap:Header>
<soap:Body>
<ns2:ResponseData>
<ns2:Employee >
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>2</ns4:Code>
<ns4:Source>Emp</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>1</ns4:Code>
<ns4:Source>contract</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
</ns2:Employee>
</ns2:ResponseData>
</soap:Body>
</soap:Envelope>
My Requirement is, copy complete input xml elements and attributes to output xml include all namespaces except xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/". So Desire Output is:
My Requirement is, copy complete input xml elements and attributes to output xml include all namespaces except xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/". So Desire Output is:
<Envelope
xmlns:ns="http:test/201/2"
xmlns:m0="http:test/201/3"
xmlns:ns0="http:test/201/4"
xmlns:ns2="http:test/201/5"
xmlns:ns1="http:test/201/6"
xmlns:ns3="http:test/201/7"
xmlns:ns6="http:test/201/8"
xmlns:ns4="http:test/201/9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<ns0:ResponseHeader>
<ns:Env>Dev</ns:Env>
<ns:Version>1</ns:Version>
<ns:Server></ns:Server>
<ns:Name>NAME</ns:Name>
</ns0:ResponseHeader>
</Header>
<Body>
<ns2:ResponseData>
<ns2:Employee >
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>2</ns4:Code>
<ns4:Source>Emp</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>1</ns4:Code>
<ns4:Source>contract</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
</ns2:Employee>
</ns2:ResponseData>
</Body>
</Envelope>
Upvotes: 0
Views: 893
Reputation: 3412
DataPower only implements XSLT 1.0, not 2.0.
You can control your namespaces through Copy:
<xsl:copy>
<xsl:element name="ns:Element" namespace="http://www.xml.com/ns">
</xsl:copy>
Upvotes: 0
Reputation: 167716
If you want to transform all soap:foo
elements to foo
elements in no namespace and remove the soap
namespace then using
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
exclude-result-prefixes="xs soap"
version="2.0">
<xsl:template match="@* | node()">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="soap:*">
<xsl:element name="{local-name()}">
<xsl:copy-of select="namespace::*[not(. = namespace-uri(current()))]"/>
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
should suffice, assuming your root element is in the soap namespace and has all the namespace declarations in scope.
When I apply above XSLT to the input sample
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http:test/201/2"
xmlns:m0="http:test/201/3"
xmlns:ns0="http:test/201/4"
xmlns:ns2="http:test/201/5"
xmlns:ns1="http:test/201/6"
xmlns:ns3="http:test/201/7"
xmlns:ns6="http:test/201/8"
xmlns:ns4="http:test/201/9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<ns0:ResponseHeader>
<ns:Env>Dev</ns:Env>
<ns:Version>1</ns:Version>
<ns:Server></ns:Server>
<ns:Name>NAME</ns:Name>
</ns0:ResponseHeader>
</soap:Header>
<soap:Body>
<ns2:ResponseData>
<ns2:Employee >
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>2</ns4:Code>
<ns4:Source>Emp</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>1</ns4:Code>
<ns4:Source>contract</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
</ns2:Employee>
</ns2:ResponseData>
</soap:Body>
</soap:Envelope>
in your post then Saxon 9.6 creates the result
<?xml version="1.0" encoding="UTF-8"?><Envelope xmlns:ns="http:test/201/2" xmlns:m0="http:test/201/3" xmlns:ns0="http:test/201/4" xmlns:ns2="http:test/201/5" xmlns:ns1="http:test/201/6" xmlns:ns3="http:test/201/7" xmlns:ns6="http:test/201/8" xmlns:ns4="http:test/201/9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<ns0:ResponseHeader>
<ns:Env>Dev</ns:Env>
<ns:Version>1</ns:Version>
<ns:Server/>
<ns:Name>NAME</ns:Name>
</ns0:ResponseHeader>
</Header>
<Body>
<ns2:ResponseData>
<ns2:Employee>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>2</ns4:Code>
<ns4:Source>Emp</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
<ns2:MessageList xsi:type="ns3:Info">
<ns2:Message>
<ns4:Type>new</ns4:Type>
<ns4:Code>1</ns4:Code>
<ns4:Source>contract</ns4:Source>
<ns4:Description>new hire</ns4:Description>
</ns2:Message>
</ns2:MessageList>
</ns2:Employee>
</ns2:ResponseData>
</Body>
</Envelope>
Upvotes: 0