xsl-list
[Top] [All Lists]

Creating multi-level groupings

2004-08-30 05:35:04
I am trying to create a HTTP table using the following data, however, I want it 
grouped on multiple fields (namely "product", "doc_type" & "customer").

I've manage to group on one field (see bottom of mail) but can't find info on 
extending this to more than one key.


--------------------------Start of XML 
------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="VitalVolumes4.xsl"?>
<!-- Vital Document Volumes Database -->
<volume>
        <product>01 Vital ABC
                <doc>
                        <doc_type>02 External Reqs</doc_type>
                        <customer>Government</customer>
                        <id>3246.01.02.01.01</id>
                        <title>Specification Document for the FR trial</title>
                </doc>                  
                <doc>
                        <doc_type>02 External Reqs</doc_type>
                        <customer>NASA</customer>
                        <id>3246.01.02.02.01</id>
                        <title>Placeholder for T-Mobile Doc</title>
                </doc>
        </product>
        <product>02 Vital XYZ
                <doc>
                        <doc_type>01 Type</doc_type>
                        <customer>Customer A</customer>
                        <id>3246.02.01.01.01</id>
                        <title>CSD for Customer A - Vital XYZ</title>
                </doc>                  
                <doc>
                        <doc_type>05 Another Type</doc_type>
                        <customer>Customer B</customer>
                        <id>3246.02.05.01.01</id>
                        <title>Some other document</title>
                </doc>
        </product>
</volume>
----------------End of XML-----------------------------------

----------------Start of XSL--------------------------------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:key name="docs_by_doc_type" match="doc" use="doc_type"/>
..
..
<xsl:for-each select="doc[count(. | key('docs_by_doc_type', doc_type)[1]) = 1]">
                        <xsl:sort select="doc_type"/>
                        <tr>
                                <td colspan="4">
                                        <xsl:value-of select="doc_type"/>
                                </td>
                        </tr>
                        <xsl:for-each select="key('docs_by_doc_type', 
doc_type)">
                                <xsl:sort select="id"/>
                                <tr>
                                        <td/>
                                        <td>
                                                <xsl:value-of select="id"/>
...
.
.
.
----------------End of XSL-----------------------------------




<Prev in Thread] Current Thread [Next in Thread>