|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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@xxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








