xsl:copy problem

Subject: xsl:copy problem
From: "Kiel, Paul" <pkiel@xxxxxxxxxx>
Date: Thu, 27 Apr 2000 08:37:21 -0400
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