내 xslt 코드에서 copy-of를 사용하여 요소와 그 자손 노드를 복사 할 수 있지만 결과 스키마는 동일한 구조를 갖지만 다른 구조를가집니다. 네임 스페이스. 여전히 사본을 사용하고이를 수행 할 수있는 방법이 있습니까? XSLT 2.0을 사용 중입니다결과 문서의 다른 네임 스페이스에 xslt 복사
다음은 소스 및 대상 XML의 예입니다. cd 요소는 XSL의 copy-of를 사용하여 복사 할 수 있지만 다른 네임 스페이스가 있습니다.
소스 XML
<catalog xmlns="namespace1">
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
대상 XML
<books xmlns="namespace2">
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</books>
마틴 Honnen의 아이디어를 사용하고 생성이
<xsl:template name="changeNamespace">
<xsl:param name="nodes"/>
<xsl:for-each select="$nodes">
<xsl:choose>
<xsl:when test="count(child::*)>0">
<xsl:element name="newnamespace:{local-name()}">
<xsl:call-template name="changeNamespace">
<xsl:with-param name="nodes" select="./child::*"/>
</xsl:call-template>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="newnamespace:{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
코드로 문제를 제대로 설명해 주실 수 있습니까? – Shuvra