2017-10-19 10 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>