homepage Welcome to WebmasterWorld Guest from 54.237.235.12
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
Basic help on copying elements using XSL
Beezer900



 
Msg#: 4336896 posted 12:22 pm on Jul 8, 2011 (gmt 0)

In my XSL, I'm trying to copy a complex element, **then** apply a template to it. Currently the templates are only being applied to the children of the copied element.

Thanks for your help... I appreciate this is basic stuff.

This is what I'm trying, which is clearly wrong.



<xsl:template match="activity">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
<div class="activity">
<xsl:apply-templates />
</div>
</xsl:template>


 

httpwebwitch

WebmasterWorld Administrator httpwebwitch us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4336896 posted 1:35 pm on Jul 8, 2011 (gmt 0)

Welcome to WebmasterWorld!

<xsl:copy> is a "shallow" copy, and (according to the manual) only copies the current node. <xsl:copy-of> is a "deep" copy, which does a recursive copy of all the node's children.

Have you tried matching the parent of "activity" instead?

Beezer900



 
Msg#: 4336896 posted 2:08 pm on Jul 8, 2011 (gmt 0)

I can use <xsl:copy-of select="activity" /> in the matched parent, and this copies the nodes from the XML. How do I then apply the <xsl:template match="activity"> to this copied output?

I seem to be able to use <xsl:apply-templates /> only when using <xsl:copy>, not copy-of.

I'm so confused!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved