<xsl:copy>-Element

Kopiert den aktuellen Knoten von der Quelle zur Ausgabe.

<xsl:copy
  use-attribute-sets = QNames
</xsl:copy>

Attribute

  • use-attribute-sets
    Eine durch Leerraum getrennte Liste von Attributgruppen, die als eine Liste von Qualifizierte Namen (XSLT) angegeben sind. Durch Angeben dieses Attributs wird jedes Attribut in jeder aufgelisteten Attributgruppe deklariert.

Elementinformationen

Anzahl der Vorkommen

Unbegrenzt

Übergeordnete Elemente

xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:fallback, xsl:for-each, xsl:if, xsl:message, xsl:otherwise, xsl:param, xsl:processing-instruction, xsl:template, xsl:variable, xsl:when, xsl:with-param, Ausgabeelemente

Untergeordnete Elemente

xsl:apply-templates, xsl:attribute, xsl:call-template, xsl:choose, xsl:comment, xsl:copy, xsl:copy-of, xsl:element, xsl:for-each, xsl:if, xsl:processing-instruction, xsl:text, xsl:value-of, xsl:variable, Ausgabeelemente

Hinweise

Das <xsl:copy>-Element erstellt einen Knoten in der Ausgabe mit demselben Namen, Namespace und Typ wie der aktuelle Knoten. Attribute und untergeordnete Elemente werden nicht automatisch kopiert. Dieses Element ermöglicht Identitätstransformationen.

Beispiel

Im folgenden Beispiel wird eine Identitätstransformation für ein gesamtes Dokument durchgeführt. Die Identitätstransformation kopiert jeden Knoten in der Quelle in die Ausgabe, um eine logisch äquivalente Struktur bereitzustellen. Dies ergibt keine Äquivalenz der Zeichen: Entitäten werden erweitert und Leerräume, die nicht als signifikant markiert wurden, werden möglicherweise entfernt.

XML-Datei (booksshort.xml)

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="identityxfm.xsl"?>
<catalog>
    <book id="bk101">
        <author>Gambardella, Matthew</author>
        <title>XML Developer's Guide</title>
        <genre>Computer</genre>
        <price>44.95</price>
        <publish_date>2000-10-01</publish_date>        
        <description>An in-depth look at creating applications with
 XML.</description>
    </book>
    <book id="bk102">
        <author>Ralls, Kim</author>
        <title>Midnight Rain</title>
        <genre>Fantasy</genre>
        <price>5.95</price>
        <publish_date>2000-12-16</publish_date>
        <description>A former architect battles corporate zombies,
 an evil sorceress, and her own childhood to become queen of the
 world.</description>
    </book>
    <book id="bk103">
        <author>Corets, Eva</author>
        <title>Maeve Ascendant</title>
        <genre>Fantasy</genre>
        <price>5.95</price>
        <publish_date>2000-11-17</publish_date>
        <description>After the collapse of a nanotechnology society
 in England, the young survivors lay the foundation for a new 
society.</description>
    </book>
</catalog>

XSLT-Datei (identityxfm.xsl)

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

  <xsl:template match="/ | @* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Ausgabe

Dies ist ein Teil der formatierten Ausgabe, die an der rechten Seite abgeschnitten wurde:

Gambardella, MatthewComputer44.952000-10-01An in-depth look and her own childhood to become queen of the world.Corets, EvaFa

Dies ist die Prozessorausgabe:

<?xml version="1.0"?><?xml-stylesheet type="text/xsl"

href="identityxfm.xsl"?><catalog><book id="bk101"><author>Gambardella,

Matthew</author><title>XML Developer's

Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000

-10-01</publish_date><description>An in-depth look at creating

applications with

XML.</description></book><book id="bk102">

...

</book></catalog>