[xsl] Multi Level Grouping using Muenchian Grouping

Subject: [xsl] Multi Level Grouping using Muenchian Grouping
From: robert.parsons@xxxxxxxxxxxxxx
Date: Wed, 31 Jul 2002 11:40:06 +0000 (GMT)
Hi

I have attempted to implement multi level grouping using Muenchian
Grouping. My attempt is based on the example in the XSL List archive,
but somewhere along the line I seem to have lost the plot. Could
someone look at my attempt and point me in the right direction. The
source XML XSLT and required output are shown below.

Source XML

<?xml version="1.0" encoding="UTF-8" ?>
<assets>
   <asset level="1" id="2">
      <assetname>OSSP SW Management</assetname>

     
<url>http://rochstrweb.rochstr.gmav.gecm.com/avionic-systems/engineeri
ng/software/assets/supp_policy/OSSP_SW_Management.doc</url>

      <reference>V6.0</reference>

      <processareas>
         <processarea>2</processarea>

         <processarea>4</processarea>
      </processareas>
   </asset>

   <asset level="2" id="23">
      <assetname>Software Strategy and Tailoring Process</assetname>

     
<url>http://www4.rochstr.gmav.gecm.com/ENG/sw_eng/assets/as_assets/gen
_docs/as_pi_wi/as-pi-wi-006.doc</url>

      <reference>AS/PI/WI/006</reference>

      <processareas>
         <processarea>2</processarea>
      </processareas>
   </asset>

   <asset level="1" id="1">
      <assetname>OSSP SW Types</assetname>

     
<url>http://rochstrweb.rochstr.gmav.gecm.com/avionic-systems/engineeri
ng/software/assets/supp_policy/OSSP_SW_Types.doc</url>

      <reference>V4.0</reference>

      <processareas>
         <processarea>3</processarea>
      </processareas>
   </asset>

   <asset level="1" id="1">
      <assetname>OSSP SW Types</assetname>

     
<url>http://rochstrweb.rochstr.gmav.gecm.com/avionic-systems/engineeri
ng/software/assets/supp_policy/OSSP_SW_Types.doc</url>

      <reference>V4.0</reference>

      <processareas>
         <processarea>2</processarea>
      </processareas>
   </asset>
</assets>

XSLT

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:output method="html" encoding="utf-8" />

   <xsl:key name="assets-by-processarea" match="asset"
use="processareas/processarea" />

   <xsl:key name="assets-by-level" match="asset"
use="concat(processareas/processarea, ' ',@level)" />

   <xsl:variable name="process" select="key('assets-by-processarea',
'2 ')" />

   <xsl:template match="assets">
      <xsl:for-each
select="$process[generate-id()=generate-id(key('assets-by-level',
      concat(processareas/processarea, ' ',@level))[1])]">
         <xsl:if test="(@level='1')">
            <h1>AS Policies:</h1>
         </xsl:if>

         <xsl:if test="(@level='2')">
            <h1>General:</h1>
         </xsl:if>
		
         <a href="url"><xsl:value-of select="assetname"/></a>
      </xsl:for-each>
   </xsl:template>
</xsl:stylesheet>

HTML required output assuming processarea = 2

AS Policies

OSSP SW Types
OSSP SW Management

General

Software Strategy and Tailoring Process

I have managed to get this working to the extent that it would pick
out first entry at each level, but in trying to get it to get the
required data It doesnt' work at all at the moment. 

TIA

Rob



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread