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

RE: Comparing previous

Subject: RE: Comparing previous
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 19 Mar 2002 08:43:37 -0000
xslt previous node
> I'm hoping someone can help me. Here's my problem:
>
> I am accessing a sorted node list using apply-templates and wish to
> compare against the previous node in the sorted node set when
> accessing
> the current node in the matched template.

There is no way of doing this.

> I was thinking self::node()[position()-1], but this doesn't seem
> to work.

No, this definitely won't work, for several reasons. self::node() always
selects a single node, and the numeric predicate [position()-1] is short for
[position()=position()-1] which is always false.
>
> FWIW there are multiple wk_wks nodes and multiple
> wk_wks_parcel nodes as
> children to the wk_wks nodes. wk_wks_parcel nodes may be
> repeated across
> multiple  wk_wks nodes. My goal is to display them all in a list but
> only once.
>
For all problems that involve eliminating duplicates or grouping, look at
Muenchian grouping techniques as described in Chapter 9 of my book, or at
http://www.jenitennison.com/xslt/grouping.

It may be that in this case a simpler two-pass solution is appropriate: sort
the original data into a result tree fragment, then process this fragment
(using xx:node-set()), testing each node with the condition xsl:if
test="not(@x = preceding-sibling::*[1]/@x)".

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


 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.