In meinem XSLT-Code kann ich kopieren, um das Element und seine Nachkommen Knoten zu kopieren, aber der Haken ist, dass das resultierende Schema hat jedoch die gleiche Struktur hat eine andere Namensraum. Gibt es irgendeinen Weg, den ich noch kopieren und durchführen kann? Ich verwende XSLT 2.0xslt copy-of in verschiedenen Namespace im resultierenden Dokument
Nachstehend ist das Beispiel der Quell- und Ziel-XMLs, die CD-Elemente können kopiert werden mit Kopie von in XSL, aber sie haben unterschiedliche Namespaces.
Quelle 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>
Ziel 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>
Gebrauchte Martin Honnen Idee und schuf dieses
<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>
Können Sie bitte das Problem richtig mit Code erklären? – Shuvra