Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2006, 12:09 PM
Authorized User
 
Join Date: Oct 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy all contents except current node in XSLT

I have the following XML:

<FruitBasket>
   <Apple>3</Apple>
   <Bannana>2</Bannana>
   ...
</FruitBasket>

I like to create new XML with this result:

<WhatNeeded>
   <Apple>3</Apple>
   <Bannana>2</Bannana>
   ...
</WhatNeeded>

My current XSLT is the following:

<xsl:template name="FruitBasket>
   <WhatNeeded>
   <xsl:copy-of select="."/>
   </WhatNeeded>
</xsl:template>

But my result came to be the following:

<WhatNeeded>
   <FruitBasket>
      <Apple>3</Apple>
      <Bannana>2</Bannana>
      ...
   </FruitBasket>
</WhatNeeded>

Here is my question. Is there a way to copy all contents, except the current node's tag, using copy-of? I don't want to copy the <FruitBasket> tag. Beside copy-of, are there any other commands that I should use?
 
Old December 19th, 2006, 12:22 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

<xsl:copy-of select="child::node()"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 19th, 2006, 06:44 PM
Authorized User
 
Join Date: Oct 2006
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. Appreciate the help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help to check the current node... darshil XSLT 1 May 9th, 2007 02:42 AM
XSLT Going up a level from current node. lafilip XSLT 4 February 23rd, 2007 03:06 PM
"for-the-current-node" instead of "for-each" ? webhead XSLT 2 August 25th, 2006 02:55 PM
Search the contents of a node azbij XSLT 1 August 18th, 2005 04:03 AM
Copy workbook contents into new one crmpicco Excel VBA 0 May 17th, 2005 05:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.