XSL を適用し、それを上位バージョンの別の XML に変換する必要があるこの入力 XML があります。V3としましょう。したがって、入力 XML はバージョン V1 です。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:NS1="http://www.test1/Error/v1"
xmlns:NS2="http://www.test1/Error/schema/SCRIPT"
xmlns:tns="http://www.test1/webservice/Service/v1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<tns:Sample>
<NS2:Message release="006" version="010">
<NS2:Header>
<NS2:TestMessage>1</NS2:TestMessage>
</NS2:Header>
<NS2:Body>
<NS2:SampleTx>
<NS2:Element1>
<NS2:IdName>
<NS2:ID>
<NS2:IDValue>114</NS2:IDValue>
</NS2:ID>
</NS2:IdName>
</NS2:Element1>
</NS2:SampleTx>
</NS2:Body>
</NS2:Message>
</tns:Sample>
</soapenv:Body>
</soapenv:Envelope>
私が適用しているXSLは
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:djh="http://www.test1/webservice/Service/v1"
xmlns:NS1="http://www.test1/Error/v1"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output indent="yes"/>
<xsl:template match="@*|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="djh:*">
<xsl:element name="{name()}" namespace="http://www.test1/webservice/Service/v3">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
そして私が得る出力は
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<tns:sendCancelRx xmlns:tns="http://www.test1/webservice/Service/v3">
<NS2:Message release="006" version="010"
xmlns:NS2="http://www.ncpdp.org/schema/SCRIPT">
<NS2:Header>
<NS2:TestMessage>1</NS2:TestMessage>
</NS2:Header>
<NS2:Body>
<NS2:SampleTx>
<NS2:Element1>
<NS2:IdName>
<NS2:ID>
<NS2:IDValue>114</NS2:IDValue>
</NS2:ID>
</NS2:IdName>
</NS2:Element1>
</NS2:SampleTx>
</NS2:Body>
</NS2:Message>
</tns:sendCancelRx>
</soapenv:Body>
</soapenv:Envelope>
からすべての名前空間宣言を取り除きますxmlns:NS1="http://www.test1/Error/v1" xmlns:NS2="http://www.test1/Error/schema/SCRIPT" xmlns:tns="http://www.test1/webservice/Service/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
そして、私が望む出力は
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:NS1="http://www.test1/Error/v3"
xmlns:NS2="http://www.test1/Error/schema/SCRIPT"
xmlns:tns="http://www.test1/webservice/Service/v3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<tns:Test>
<NS2:Message release="006" version="010">
<NS2:Header>
<NS2:TestMessage>1</NS2:TestMessage>
</NS2:Header>
<NS2:Body>
<NS2:SampleTx>
<NS2:Element1>
<NS2:IdName>
<NS2:ID>
<NS2:IDValue>114</NS2:IDValue>
</NS2:ID>
</NS2:IdName>
</NS2:Element1>
</NS2:SampleTx>
</NS2:Body>
</NS2:Message>
</tns:Test>
</soapenv:Body>
</soapenv:Envelope>
私の XSL に欠けているものを教えていただければ幸いです。