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> ... |
Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.