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

xsl:copy problem

Subject: xsl:copy problem
From: "Kiel, Paul" <pkiel@xxxxxxxxxx>
Date: Thu, 27 Apr 2000 08:37:21 -0400
copy problem
I am trying to copy a tree in its entirety with an exception.   

Essentially I want to insert <Element> elements wherever a <tag> element
occurs, based on a matching attribute "name":

<root>
   <Element  name="Hello"> content_I_want_to_keep </Element>
   <Element  name="Barney"> more_content_I_want_to_keep </Element>

   <Element  name="George"> 
       <tag name="Hello"/> <!-- insert Element name="Hello" here in result
tree-->
       <tag name="Barney"/> <!-- insert Element name="Barney" here in result
tree-->
   </Element>
   
</root>

The result I want:

<root>
   <Element  name="Hello"> content_I_want_to_keep </Element>
   <Element  name="Barney"> more_content_I_want_to_keep </Element>

   <Element  name="George"> 
       <Element  name="Hello"> content_I_want_to_keep </Element>
       <Element  name="Barney"> more_content_I_want_to_keep </Element>
   </Element>
   
</root>

Templates:

<xsl:template match="tag">
        <xsl:copy-of select="//Element[@name='Hello']"/> <!-- this line
works fine, but is too literal-->
        <xsl:copy-of select="//Element[@name='@name']"/> <!-- this line
doesn't work - why?-->
</xsl:template>

<xsl:template match="Element">
        <xsl:copy-of select="."/>
</xsl:template>

I am using James Clark's XT.  Have tried many variations in the "tag"
template to no avail.  Am I making an XPath mistake, or is it something to
do with xsl:copy-of?	

Thanks in advance,

Paul Kiel
Sertus Software
pkiel@xxxxxxxxxx



 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.