2017-10-19 1 views
-1

Aktuelle KopfXSLT-Header Probleme

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

New header

<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"> 

Ich versuchte dies:

<?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> 

Sie haben Recht (deleted der falsche Code), um mein Problem zu erstellen ist xmlns = "http://www.gs1.nl/factuur/insbou/004". Hoffe, du kannst mir helfen. Danke

+1

Es ist nicht klar, was das Problem ist ... – Ray

+0

Das Problem : ich kann nicht hinzufügen xmlns = "http://www.gs1.nl/factuur/insbou/004" – LDH

Antwort

0

Sie müssen verstehen, dass der Namespace Teil des qualifizierten Namen jedes Elements in dem Dokument ist, so dass Sie den Namespace jeder Verwendung ändern müssen, z.

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

und dann auf Ihrem Stylesheet-Root können Sie einfach den gewünschten Namespace deklarieren. Aber wie Sie zusätzlich ein Attribut zu dem Wurzelelement hinzufügen möchten, und auszulassen andere benötigen Sie auch eine Vorlage, das zu tun, so mit allen Änderungen müssen Sie

<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>