|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Grouping and filtering
| 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>
</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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








