This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

xsl: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@sertus.com



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]