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

Followup question about transforming node location

Subject: Followup question about transforming node location
From: Jonathan Schroeder <jschroeder_1998@xxxxxxxxx>
Date: Thu, 27 Apr 2000 09:40:12 -0700 (PDT)
xsl node location
As a long Easter weekend delayed my response to Mike's
helpful reply, I am reposting my followup question:

Mike,

Thanks for your help! I think I now have a better
understanding of when to use copy, copy-of and
apply-templates.

I was wondering if you might be able to provide some
additional guidance. I am trying to do a
transformation (slightly different from the one
described in my previous post) by renaming a node and
its children and moving this newly named node to a
particular location in the output. I know the element
that will precede the intended output location, but
the elements before this element can vary. The
following XSL (I modified slightly the XSL you
provided) renames and moves the node as desired, but I
am looking to change the <xsl:copy-of select="tag2"/>
to something more generic, so that I can copy
everything (except tag1) as is and then once I have
copied tag2 to the output, tag1 will be transformed
through a template. The copying will then resume
generically for the rest of the document, as the
subsequent elements may vary.

<xsl:template match="document">
<xsl:copy>
  <xsl:copy-of select="tag2"/>
  <xsl:apply-templates select="tag1"/>
  <xsl:copy-of select="tag3"/>    
</xsl:copy>
</xsl:template>

<xsl:template match="tag1">
<newtag1><xsl:apply-templates/></newtag1>
</xsl:template>

<xsl:template match="element1">
<newelement1><xsl:apply-templates/></newelement1>
</xsl:template>

<xsl:template match="element2">
<newelement2><xsl:apply-templates/></newelement2>
</xsl:template>

I would like to take this input:
<document>
   <tag1>
     <element1>tag1data1</element1>
     <element2>tag1data2</element2>
   </tag1>
   <tag15>
     <element1>tag15data1</element1>
     <element2>tag15data2</element2>
   </tag15>
   <tag2>
     <element1>tag2data1</element1>
     <element2>tag2data2</element2>
   </tag2>
   <tag3>
     <element1>tag3data1</element1>
     <element2>tag3data2</element2>
   </tag3>
 </document>

and create the output:
 <document>
   <tag15>
     <element1>tag15data1</element1>
     <element2>tag15data2</element2>
   </tag15>
   <tag2>
     <element1>tag2data1</element1> 
     <element2>tag2data2</element2> 
   </tag2>
   <newtag1>
     <newelement1>tag1data1</newelement1> 
     <newelement2>tag1data2</newelement2> 
   </newtag1>
   <tag3>
     <element1>tag3data1</element1> 
     <element2>tag3data2</element2> 
   </tag3>
 </document>

Any help is much appreciated.

Jonathan




__________________________________________________
Do You Yahoo!?
Talk to your friends online and get email alerts with Yahoo! Messenger.
http://im.yahoo.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.