O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Copying Elements

When you copy elements from one XML document to another, you will likely place the element in a new place in the structure. Sometimes you will want to copy an element only (without any child elements); other times, you might want to copy an element together with any content that it has. The first type of copy is called a shallow copy, and the second type is called a deep copy.

Shallow Copy

In XSLT, a shallow copy is carried out using the xsl:copy element. Listing 11.1 shows a simple purchase order for training services.

Listing 11.1. PurchaseOrder.xml: A Purchase Order in XML
 <?xml version='1.0'?> <PurchaseOrder> <Date>2003/02/20</Date> <To>XMML Training Services</To> <From>Acme Computing</From> <Items> <Item> <StockNumber>DBI99</StockNumber> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required