Subject: Re: [xsl] How to duplicate an entire subtree From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 26 Dec 2008 19:56:50 -0500 |
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: ... The output have to be like this: ... I tried this script (and several variants of it): ... The disconcerting thing is that I'm able to achieve just the text elements whitout the XML structure.
Have a look to the output: ... Who can help me, please?
t:\ftemp>type nick.xml <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>
t:\ftemp>type nick.out <?xml version="1.0" encoding="UTF-16"?> <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>
t:\ftemp>type nick.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="book"> <xsl:copy-of select="."/> <xsl:copy-of select="."/> </xsl:template>
<xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
t:\ftemp>echo Done! Done!
-- Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes: : Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to duplicate an entir, Raymond Bissonnette | Thread | RE: [xsl] How to duplicate an entir, Michael Kay |
RE: [xsl] How to duplicate an entir, Raymond Bissonnette | Date | Re: [xsl] multiple files to single , G. Ken Holman |
Month |