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

group-by deep equality?

Subject: group-by deep equality?
From: David Sewell <dsewell@xxxxxxxxxxxx>
Date: Tue, 10 Jan 2006 16:13:55 -0500 (EST)
deep equality
I'm trying to figure out how to group elements by deep equality of node
sequences. Given input data like this:

<list>
   <item n="1">Life of Brian</item>
   <item n="2"><i>Life</i> of Brian</item>
   <item n="3">Life of Brian</item>
   <item n="4"><i>Life of Brian</i></item>
</list>

I want groups of <item> elements whose contents that are all deep-equal() to one
another. So in this case there should be three groups:

   <item n="1">Life of Brian</item>
   <item n="3">Life of Brian</item>

   <item n="2"><i>Life</i> of Brian</item>

   <item n="4"><i>Life of Brian</i></item>

<xsl:for-each-group select="item" group-by="."> creates only one group,
because the atomic value of each <item> node is the concatenated value
of descendant text nodes, i.e. "Life of Brian" in each case.

For the above data, the following will in fact produce the desired three groups:

  <xsl:for-each-group select="item" group-by="concat(., count(.//node()))">

but it's not a generalizable solution because it would treat

   <item n="5">Life of <i>Brian</i></item>

as equivalent to item #2 (they both have 3 descendant nodes).

Is there a pure @group-by solution, or will this require something more
complicated involving @group-by-adjacent and deep-equal()?

-- 
David Sewell, Editorial and Technical Manager
Electronic Imprint, The University of Virginia Press
PO Box 400318, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: dsewell@xxxxxxxxxxxx   Tel: +1 434 924 9973
Web: http://www.ei.virginia.edu/

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.