[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Remove Duplicates from Recursive Template Calls

Subject: Re: Remove Duplicates from Recursive Template Calls
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 3 May 2005 15:12:02 +0100
xsl remove duplicates
> I can't use the ".=preceding" because I'm using recursive template
> calls. 

Why does the test for whether this is teh first node in a document
      depend on whether the template invocation is recursive?

      <xsl:for-each select="//component/@id[.=$idRef]//..">

that's a very odd XPath. selecting the parent of every node below
$idRef.


As a side issue I note that you are combining  indent="yes" with
explictly addded indentation eg


          <xsl:value-of select="$indent"/>
          (<xsl:value-of select="@estimate"/>)

which adds the value of $indent followed by 10 spaces and a ( before the
estimate.

Results are usually more consistent across systems if you either turn
off automatic indent and do it all by hand or make sure that there
is no white space in the output and just let the system do it.
The specification for what indentation is supposed to do in the
presence of mixed content is rather under-specified.


>  I tried to find a way to set an attribute in the source document to
>  indicate that the component has been processed, but I can not find a
>  method to do that.  I tried to flag the processed nodes, but I can't
>  find a method to do that either 

The input tree is read-only in XSLT.

If you need to omit elements if they have been processed earlier rather
than if they occur earlier in teh document it's probably simpler to do
two passes.

First do your existing stylesheet into a variable, and then do a second
pass to remove duplicates.

<xsl:template match="/">
<xsl:variable name="x">
<xsl:apply-templates/>
</xsl:variable>
<xsl:apply-templates select="xalan:node-set($x)"/>
</xsl:template>


The templates in the second pass (which you can put in a separae mode if
they would clash with your first pass) just need to be an identity
transform with extra templates to filter out whatever needs filtering.

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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.