2016-12-02 7 views
0

既存の名前空間を削除し、別の名前空間をXML文書に追加しようとしています。私は属性を追加しなかったとき、それは働いていた。さて、属性 "id"を追加すると、削除コードは機能しません。XSLTを使用した名前空間の削除が機能しない

私のXMLドキュメントは、次のとおりです。

<?xml version="1.0" encoding="UTF-8"?> 

<n0:eCPR xmlns:prx="urn:sap.com:proxy:DV4:/1SAI/TAS1F59A417878D36573F1D:700:2013/05/24" xmlns:n0="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"> 

<n0:employees> 
    <n0:employee> 
    <n0:name id="20019768">Paul John</n0:name> 
</n0:employee> 
</n0:employees> 
</n0:eCPR> 

が、私はそれになりたいどのようなものです:私は(私の前のポストUnable to Update the Namespace of XML Documentを使用する前に働いていた)を適用した

<CPR:eCPR xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"> 
<CPR:employees> 
    <CPR:employee> 
    <CPR:name id="12345">JOHN SMITH</CPR:name> 
    </CPR:employee> 
</CPR:employees> 
</CPR:eCPR> 

XSLTコード:

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"> 
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
<xsl:strip-space elements="*"/> 

    <xsl:template match="*"> 
    <xsl:element name="CPR:{local-name()}"> 
    <xsl:apply-templates/> 
    </xsl:element> 
    </xsl:template> 

</xsl:stylesheet> 

答えて

1

入力に属性がある場合は、次の操作を行う必要があります。

<xsl:copy-of select="@*"/> 

あなたが行う前に:

<xsl:apply-templates/> 
+0

あなたの岩の男を!いつも助けて! –

関連する問題