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

Re: Grouping and filtering

Subject: Re: Grouping and filtering
From: "Steve Muench" <Steve.Muench@xxxxxxxxxx>
Date: Wed, 3 Jul 2002 16:28:54 +0200
bernard delporte
| What I want to produce as output is as follows:
| 
| I want to list all the groups containing the item:
| 1. for all single items
| any GR1, GR2
| test GR1
| tests GR1, GR2
| value GR2
| zz GR1

For this one, you can try a stylesheet like:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:key name="x" match="group" use="item"/>
  <xsl:key name="y" match="item"  use="."/>
  <xsl:output method="text"/>
  <xsl:template match="/">
    <xsl:for-each select="/groups/group/item[
                            generate-id() = 
                            generate-id(key('y',.)[1])]">
      <xsl:sort select="."/>
      <xsl:variable name="curitem" select="."/>
      <xsl:value-of select="$curitem"/>
      <xsl:text>: </xsl:text>      
      <xsl:for-each select="key('x',$curitem)">
        <xsl:value-of select="@name"/>
        <xsl:if test="position() != last()"><xsl:text> </xsl:text></xsl:if>
      </xsl:for-each>
      <xsl:text>&#xa;</xsl:text>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

| 2. for items responding to a certain filtering criteria like starting by
| for instance 'te'
| test GR1
| tests GR1, GR2

For this, just add an extra predicate to the outer filter like this:

    <xsl:for-each select="/groups/group/item[
                            generate-id() = 
                            generate-id(key('y',.)[1])][contains(.,'te')]">


Hope this helps.


__________________________________________________________________
Steve Muench - Developer, Product Mgr, Java/XML Evangelist, Author
Simplify J2EE and EJB Development with BC4J
http://otn.oracle.com/products/jdev/htdocs/j2ee_bc4j.html
Building Oracle XML Apps, www.oreilly.com/catalog/orxmlapp




 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.