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

Re: Grouping by key

Subject: Re: Grouping by key
From: gopinath.emmidisetty@xxxxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 2 Dec 2004 16:19:51 +0000
xsl if key
Hi,

Here is the working xsl file.  I have removed the select with null string 
for <xsl:param name="collapse" /> as suggested.  It is still not working.

I have now commented the code between <xsl:if> and</xsl:if> elements so it 
is working with collapsing all categories.  So, it works without 
<xsl:template match="/"> block.

If I remove the <xsl:if> and</xsl:if> elements and retain the code between 
the elements, it works expanding all categories, ie., displaying all 
records for that category. 

cheers .

XSL file:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        version="1.0">
        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="catCol" select="2"/>
        <xsl:param name="indent" select="'   '"/>
        <xsl:param name="collapse"/>
        <xsl:param name="columnHeaders">
                <header>CompanyName</header>
                <header>AccountNumber</header>
                <header>Town</header>
                <header>Postcode</header>
                <header>Phone</header>
        </xsl:param>

        <xsl:key name="categorise" match="account" use="*[@colno='2']" />

<!--    First <xsl:if test="$collapse=1">
        <xsl:template match="/">
                <div>
                <xsl:apply-templates select="documents" />
                </div>
        </xsl:template>
</xsl:if> -->

        <xsl:template match="documents">
                <table>
                        <xsl:apply-templates select="account[generate-id() 
= generate-id( key( 'categorise', *[@colno=$catCol] )[1] )]" 
mode="catcols">
                                <xsl:sort select="*[@colno=$catCol]"/>
                         </xsl:apply-templates>
                </table>
        </xsl:template>
 
        <xsl:template match="account" mode="catcols">
                <xsl:if test="position()=1">
                <tr>
                        <th> <xsl:value-of 
select="msxsl:node-set($columnHeaders)/header[position()=3]" /> </th>
                        <th><xsl:value-of 
select="msxsl:node-set($columnHeaders)/header[position()=1]" /> </th>
                        <th> <xsl:value-of 
select="msxsl:node-set($columnHeaders)/header[position()=2]" /> </th>
                        <th> <xsl:value-of 
select="msxsl:node-set($columnHeaders)/header[position()=4]" /> </th>
                        <th> <xsl:value-of 
select="msxsl:node-set($columnHeaders)/header[position()=5]" /> </th>
                </tr>
                </xsl:if>
                <tr class="resultCategory">
                        <td colspan="5">
<!-- <div id="<xsl:value-of select="*[@colno=$catCol]" />"     -->
                                <div><b><xsl:value-of select="*[@colno=$catCol]" /></b> ( <xsl:value-of select="count(.|key( 'categorise', *[@colno=$catCol] ) )" /> )</div>
                        </td>

<!--    Second <xsl:if test="$collapse=1">
                        <xsl:apply-templates select="key('categorise', 
*[@colno=$catCol])" mode="catrows" />
</xsl:if> -->
                </tr>

        </xsl:template>

<!--    Third <xsl:if test="$collapse=1">
        <xsl:template match="account" mode="catrows">
                <tr class="">
                        <xsl:if test="position() mod 2 != 1">
                                <xsl:attribute 
name="class">resultAlternate</xsl:attribute>
                        </xsl:if>
                <td width="40"> <xsl:value-of select="$indent" /> </td>
                <td width="300">
                        <a> <xsl:attribute name="href">
                        /mail/goemmidi.nsf/formAccountView?open&amp;window=1&amp;ac=<xsl:value-of select="*[@colno=1]" 
/>&amp;source=<xsl:value-of select="*[@colno=8]" 
/>&amp;custtype=<xsl:value-of select="*[@colno=5]" 
/>&amp;mktseg=<xsl:value-of select="*[@colno=9]" />
                        </xsl:attribute><xsl:value-of select="*[@colno=0]" 
/></a>
                </td>
                <td width="100"> <xsl:value-of select="*[@colno=1]" /> 
</td>
                <td width="100"> <xsl:value-of select="*[@colno=3]" /> 
</td>
                <td width="100"> <xsl:value-of select="*[@colno=4]" /> 
</td>
                </tr>
        </xsl:template>
</xsl:if> -->
    </xsl:stylesheet>

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.