Re: [xsl] Remove Duplicates from Recursive Template Calls

Subject: Re: [xsl] Remove Duplicates from Recursive Template Calls
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 4 May 2005 21:55:33 +0100
> This locates the component that the componentReference refers.  The
> "//.." was a typo.  It should be "/..".  I took the extra slash out of
> the code and ran it again and the results are the same.   

Yes sorry I didn't notice that you were doing this from an attribute
node so it has no descendants so // does not select anything other than
the current attribute so it does no harm in this case.  If you executed
//.. from an element node it would be different. As I see Michael has
commente dit's more usual (but equivalent) to express
foo/@id[.='x']/.. as
foo[@id='x']


> Thank you very much for taking the time to respond.  I like your idea.
> I have a concern that apply-templates will apply all templates in the
> XSL stylesheet, when I only want this one to execute.  Can this same
> process be done with a call-template?  This two pass concept is
> foreign to me, do you know a website with good working examples? 

Jeni's site or the faq for this list will have lots of example (and teh
archives of this list have lots more) look for "identity template"
for the second pass you just need an identity template that copies al
nodes
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
plus extra templates that do whatever it is that you need to do to
specifc nodes (sorry I can't remember what the problem was now)

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread