xsl:copy

Syntax

<xsl:copy>
     Template-Body
</xsl:copy>


Postition

innerhalb des Template-Bodys


Attribute
Bezeichnung Wert Bedeutung
use-attribute-sets list-of-QNames Attribut-Sets, die dem generierten Knoten hinzugefügt werden, falls es sich um ein Element handelt

<xsl:copy>

kopiert den aktuellen Knoten des Input-Dokuments in die aktuelle Position des Output-Dokuments. Die Knoten und Attribute, die von dem zu kopierenden Knoten abhängig sind, werden ignoriert.

Abhängig vom jeweiligen Knotentyp, werden folgende Aktionen durchgeführt:

Knotentyp Attribute-Set Template-Body Output
root ignoriert ausgeführt kein
element wird dem Output hinzugefügt ausgeführt Element
text ignoriert ignoriert Textknoten
attribute ignoriert ignoriert Attributknoten
prozessing instruction ignoriert ignoriert Prozessinstruktionsknoten
comment ignoriert ignoriert Kommentarknoten
namespace ignoriert ignoriert undefiniert

Definition

XSLT Kapitel 7.5


Beispiel

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

<xsl:output method="xml"/>
    
<xsl:attribute-set name="product-info">
     <xsl:attribute name="name">
          <xsl:value-of select="name"/>
     </xsl:attribute>
     <xsl:attribute name="id-nr">
          <xsl:value-of select="id"/>
     </xsl:attribute>
</xsl:attribute-set>

<xsl:template match="/">
     <xsl:processing-instruction name="xml-stylesheet">
          <xsl:text>href="order.css" type="text/css"</xsl:text>
     </xsl:processing-instruction>
     <order>
          <xsl:apply-templates select="shop"/>
     </order>
</xsl:template>

<xsl:template match="shop">
     <xsl:copy-of select="customer"/>
     <xsl:apply-templates select="order/product"/>
</xsl:template>

<xsl:template match="product">
     <xsl:copy use-attribute-sets="product-info">
          <price>
               <xsl:value-of select="price"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="currency"/>
          </price>
          <amount>
               <xsl:value-of select="amount"/>
          </amount>
     </xsl:copy>
</xsl:template>

</xsl:stylesheet>


© 2001 by Timo Schäfer