What is xsl:copy-of element in XSLT

In this article, we are going to explain xsl:copy-of element
  • 2294
The <xsl-copy-of> element can be used to creates a copy of the current node, this element can be used to insert multiple copies of the same set of nodes into different places in the output. Each node and all associated attribute nodes, namespace nodes, children and descendants are copied. In other words, it is a complete, unabridged copy of the set. When a root node is copied, all of the children and descendants are copied, but not the root node itself since there can only be one root.

Syntax of xsl:copy-of element

<xsl:copy-of select="EXPRESSION"/>

It has only one attribute

  • select

                  The mandatory select attribute specifies what to be copied.

Example of xsl:copy element

XML File(copyof.xml)

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="copyof.xsl"?>



    <given-name age="25">







    <given-name age="25">







XSLT File(copyof.xsl)

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

      xmlns:xsl="http://www.google.com/XSL/Transform" >

  <xsl:template match="person">


      <xsl:copy-of select="given-name"/>

      <xsl:text> </xsl:text>

      <xsl:copy-of select="family-name"/>





Amit Sumit singh

Rohan Ravi Pawar

Further Readings

You may also want to read these related articles :

 Ask Your Question 

Ask Your Question Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.