2016-04-07 9 views
0

を削除XSLTアイデンティティは変換:私は、XSLTに新しいですし、私は次のXMLから要素「入力」を削除しようとしています要素

私の入力XML:

<ns1:Input xmlns:ns1="http://www.test.org/"> 
    <Process xmlns="http://www.acord.org/...." 
       xsi:schemaLocation="http://www.acord.org/schema/... "> 
    ..... 
    </Process> 
</ns1:Input> 

予想される出力:

私は次のように変換アイデンティティを使用しています
<Process xmlns="http://www.acord.org/...." 
      xsi:schemaLocation="http://www.acord.org/schema/... "> 
     ..... 
</Process> 

<xsl:template match="@*|node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
    </xsl:template> 

xml全体をtarget xsdにコピーしていますが、削除したいinput要素でコピーしています。 クイックヘルプに感謝します。

おかげで、 cdhar

答えて

0

追加あなたは恒等変換で<xsl:copy copy-namespaces="no">...を使用する必要がありますXSLT 2.0となるよう、あなたがProcess要素のルート名前空間宣言を取得する可能性がありますどのような場合には、テンプレート

<xsl:template match="ns1:Input"> 
    <xsl:apply-templates/> 
</xsl:template> 

http://xsltransform.net/bFN1yag

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> 

    <xsl:template match="@*|node()"> 
     <xsl:copy copy-namespaces="no"> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="ns1:Input" xmlns:ns1="http://www.test.org/"> 
     <xsl:apply-templates/> 
    </xsl:template> 
</xsl:transform> 

xsl:copyの代わりに<xsl:element name="{name()}" namespace="{namespace-uri()}">でXSLT 1.0の要素を作成します。

+0

ありがとうございました。魅力のように動作します。ありがとうございました!! – user3401234