2017-10-19 11 views
-1

現在のヘッダXSLTヘッダーの問題

<Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="Factuur_insbou003.xsd"> 

新しいヘッダ

<Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://www.gs1.nl/factuur/insbou/004" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.gs1.nl/factuur/insbou/004 
          Factuur_insbou004.xsd"> 

は、私はこれを試してみました:

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       version="1.0"> 
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/> 

    <xsl:template match="/*[local-name()= 'Invoice']"> 
    <Invoice xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns="http://www.gs1.nl/factuur/insbou/004" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
     <xsl:copy-of select="node()|@*"/> 
    </Invoice> 
    </xsl:template> 


</xsl:stylesheet> 

あなたは、私の問題を作成することです(間違ったコード削除)正しいですxmlns = "http://www.gs1.nl/factuur/insbou/004"。あなたが私を助けてくれることを願います。ありがとう

+1

を必要とするすべての変更を持つので、それは問題が何であるかは明らかではない、ということテンプレートを必要とする別のものを省略したいと... – Ray

+0

問題は、 :私はcan not add xmlns = "http://www.gs1.nl/factuur/insbou/004" – LDH

答えて

0

名前空間が文書内の各要素の修飾名の一部であるため、それぞれの名前空間を変更する必要があることを理解しておく必要があります。

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

あなたのスタイルシートのルート上で、あなたが望む名前空間を単に宣言できます。しかし、あなたは、さらにルート要素に属性を追加し、あなたも、あなたが

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
     version="1.0"  
     xmlns="http://www.gs1.nl/factuur/insbou/004" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 


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

    <xsl:template match="/Invoice"> 
     <Invoice 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xsi:schemaLocation="http://www.gs1.nl/factuur/insbou/004 
          Factuur_insbou004.xsd"> 
      <xsl:apply-templates/> 
     </Invoice> 
    </xsl:template> 

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

</xsl:transform>