Click to return to the XML (Extensible Markup Language) home page    
xsl:comment Element     xsl:element Element     XSL Elements    
Web Workshop  |  XML (Extensible Markup Language)

xsl:copy Element


Copies the current node from the source to the output.

Syntax

<xsl:copy  >

Element Information

Number of occurrences Unlimited
Parent elements xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:for-each, xsl:if, xsl:otherwise, xsl:pi, xsl:template, xsl:when, output elements
Child elements xsl:apply-templates, xsl:attribute, xsl:choose, xsl:comment, xsl:copy, xsl:element, xsl:eval, xsl:for-each, xsl:if, xsl:pi, xsl:value-of, output elements
Requires closing tag Yes. XSL is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed.

Remarks

The xsl:copy element creates a node in the output with the same name, namespace, and type as the current node. Attributes and children are not copied automatically. This element makes identity transformation possible.

Example

The following example performs an identity transform on the entire document. The identity transform copies each node in the source to the output to provide a logically equivalent tree. It does not yield character-by-character equivalence—entities will be expanded, white space not marked as significant may be removed.

Note: This example is formatted for readability and might introduce unwanted white space during the transformation. To eliminate this extra white space, remove the indentations and carriage returns between the xsl elements within the template.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <xsl:template>
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

See Also

Generating More Sophisticated XML Output, Filtering XML, Copying Entire Subtrees



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.