2010-05-04 2 views
0

저는 xslt로 처음으로 작업하고 있는데, 왜이 xsl이 소스 xml에서 속성을 복사하지 않는지 이해할 수 없습니다. 아마도 누군가 나에게 힌트를 줄 수 있을까요 ??원본 xml 파일에서이 dokument 특성을 복사하지 않는 이유는 무엇입니까?

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output omit-xml-declaration="yes" indent="yes"/> 
    <xsl:variable name="rpl" select="document('ParamInvoice.xml')"/> 
    <xsl:template match="/"> 
     <xsl:copy> 
     <xsl:apply-templates select="* | @*"/> 
     </xsl:copy> 
    </xsl:template> 
    <xsl:template match="*"> 
     <xsl:variable name="vInvoiceElement" select="$rpl/StoraInvoice/*[name()=name(current())]"/> 
     <xsl:copy> 
     <xsl:if test="$vInvoiceElement/Attribute"> 
      <xsl:call-template name="AttributeErzeugen"> 
       <xsl:with-param name="pAttr" select="$vInvoiceElement/Attribute"/> 
      </xsl:call-template> 
     </xsl:if> 
     <xsl:apply-templates/> 
     </xsl:copy> 
    </xsl:template> 
    <xsl:template name="AttributeErzeugen"> 
     <xsl:param name="pAttr"/> 
     <xsl:for-each select="$pAttr"> 
     <xsl:attribute name="{@name}"><xsl:value-of select="."/></xsl:attribute> 
     </xsl:for-each> 
    </xsl:template> 
</xsl:stylesheet> 
+0

당신은 변환에 포함 된 XML 문서를 제공해야합니다 - 그렇지 않으면 사람들이 처리는 무엇을 확신 할 수 없다. –

+0

또한 속성에 의한 의미에 대해 명확히해야합니다. 코드는 실제로 외부 문서의 요소를 현재 문서의 요소와 같은 이름의 특성으로 복사합니다. 나는 어떤 오류도 여기에서 보지 않는다. – newtover

답변

0

대신 <xsl:copy-of>을 사용해야합니다. 둘 사이의 차이점은 copy이 요소 만 복사 (특성 및 하위 요소 없음)하고 copy-of이 전체 요소 (특성, 하위 항목 등)를 복사한다는 것입니다.

확인 http://www.w3schools.com/xsl/xsl_w3celementref.asp

관련 문제