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

Re: Muenchian grouping: help with 'use' and multiple

Subject: Re: Muenchian grouping: help with 'use' and multiple elements
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 9 Jul 2004 22:28:21 +0100
muenchian
Hi Justin,

> I'm trying to do single-level Muenchian grouping of r_ele elements
> by their re_restr children, of which there can be 0 to infinity
> instances in any order. I'm not sure if Muenchian grouping works
> when the 'use' element doesn't exist all the time, and I have no
> clue how to make the 'use' element consider all of the re_restr
> children in an r_ele at the same time.

I can't see a way to do this via Muenchian grouping in XSLT 1.0. You
need to be able to create the grouping key value by iterating over the
<re_restr> elements and combining their values into a string, as in:

  <xsl:for-each select="re_restr">
    <xsl:value-of select="." />
    <!-- use separator of your choice -->
    <xsl:text>,</xsl:text>
  </xsl:for-each>

It isn't possible to create this string with a single XPath 1.0
expression. So if you're using XSLT 1.0, your options are:

A. Use a two-pass transformation in which the first pass adds a 'key'
attribute to each <r_ele> element, containing the grouping key value,
and the second pass does the grouping based on that value. You'll need
to use a node-set() extension function to do this.

B. Create a user-defined function that can create the grouping key
value for a given <r_ele> element. You'll need to use an extension
element (e.g. <func:function> or <msxml:script>) to create the
user-defined function.

C. Do the grouping without using a key. This is likely to be
time-consuming (both for you writing it and for the processor running
it).

Of course, in XSLT 2.0 you can use the string-join() function:

  <xsl:for-each-group select="r_ele"
                      group-by="string-join(re_restr, ',')">
    ...
  </xsl:for-each-group>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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.