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

Eliminating duplicates while processing: the answer...

Subject: Eliminating duplicates while processing: the answer...
From: José Carlos Ramalho <jcr@xxxxxxxxxxxx>
Date: Thu, 14 Nov 2002 10:10:59 -0000
eliminating duplicates
Hi, all. Tahnk you to those who reply to my question that was:

>I want to process a list of nodes that can appear at several different
>points of the structure, and I ant to process them in a particular order.
>This is easy to specify:
>
>         for-each select="//node-name"
>             sort select="criteria"
>
>The problem is that I want to supress the node's processing if it is equal
>to the one that precedes it in that order. How can I have access to the
last
>processed node while processing the current one?
>
>TIA
>jcr


I just found a nice solution in Bob DuCharme's column at O'Reilly:
        you just need to put the following test:
            <xsl:if test="not(.=preceding::node-name)"> ...

This way you can guarantee that if you have already processed a node with
the same content of current one you skip this one.

This helped me to solve an interesting problem: I had a Bibliography XML
file regarding to a DocBook application. Each BIBLIOENTRY has a list of
authors and I wanted to transform that structure into another that for each
AUTHOR lists his entries. This is a structure inversion problem is not
trivial in a normal programming language. Spite all the tags the XSL
solution is quite nice:

<xsl:template match="/">

<UL>

<xsl:for-each select="//AUTHOR">

<xsl:sort select="SURNAME" order="ascending"/>


<xsl:if test="not(./SURNAME=preceding::SURNAME)">

<xsl:call-template name="getEntries">

<xsl:with-param name="snome" select="SURNAME"/>

</xsl:call-template>

</xsl:if>

</xsl:for-each>

</UL>

</xsl:template>



Let´s come up with some new tags...

jcr

----------------------------------------------------------------------------
---
José Carlos Ramalho                                   orienteer
Dep. Informática - U.Minho                          windsurfer
http://www.di.uminho.pt/~jcr                         engineer
+351 253 604479
----------------------------------------------------------------------------
-----



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


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.