[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: How to duplicate an entire subtree

Subject: RE: How to duplicate an entire subtree
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 27 Dec 2008 10:43:12 -0000
RE:  How to duplicate an entire subtree
You're making it much too difficult.

<xsl:template match="catalog"> 
<catalog>
  <xsl:copy-of select="book"/>
  <xsl:copy-of select="book"/>
</catalog>
</xsl:template>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: nick public [mailto:nickpubl@xxxxxxxxx] 
> Sent: 27 December 2008 00:17
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to duplicate an entire subtree
> 
> Hi experts.
> I'm using an XSL processor ver. 1 by Microsoft and I have the 
> following URGENT problem.
> I need to produce an XML output containing the duplication of a (very
> complex) node; not just the text elements but element name and
> attribute(s) too.
> An example can be this in which I want to duplicate the 
> <book> node and subs:
> 
> =========================
> <catalog>
>       <book id="bk101">
>               <author>Gambardella, Matthew</author>
>               <title>XML Developer's Guide</title>
>               <genre>Computer</genre>
>               <price>44.95</price>
>               <publish_date>2000-10-01</publish_date>
>               <description>An in-depth look at creating 
> applications with XML.</description>
>       </book>
> </catalog>
> =========================
> 
> The output have to be like this:
> 
> =========================
> <catalog>
>       <book id="bk101">
>               <author>Gambardella, Matthew</author>
>               <title>XML Developer's Guide</title>
>               <genre>Computer</genre>
>               <price>44.95</price>
>               <publish_date>2000-10-01</publish_date>
>               <description>An in-depth look at creating 
> applications with XML.</description>
>       </book>
>       <book id="bk101">
>               <author>Gambardella, Matthew</author>
>               <title>XML Developer's Guide</title>
>               <genre>Computer</genre>
>               <price>44.95</price>
>               <publish_date>2000-10-01</publish_date>
>               <description>An in-depth look at creating 
> applications with XML.</description>
>       </book>
> </catalog>
> =========================
> 
> I tried this script (and several variants of it):
> 
> =========================
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > 
> <xsl:output method='xml' indent='yes'/>
>       <xsl:template match='catalog/book'>
>               <xsl:apply-templates/>
>               <xsl:apply-templates/>
>       </xsl:template>
>       <xsl:template match='book'>
>               <xsl:copy>
>                       <xsl:apply-templates select='@*|node()'/>
>               </xsl:copy>
>       </xsl:template>
> </xsl:stylesheet>
> =========================
> 
> The disconcerting thing is that I'm able to achieve just the 
> text elements whitout the XML structure. Have a look to the output:
> 
> =========================
> Gambardella, MatthewXML Developer's 
> GuideComputer44.952000-10-01An in-depth look at creating 
> applications with XML.
> Gambardella, MatthewXML Developer's 
> GuideComputer44.952000-10-01An in-depth look at creating 
> applications with XML.
> =========================
> 
> Who can help me, please?
> Ciao. Nicola

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.