[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Hierarchical grouping question


Subject: [xsl] Hierarchical grouping question
From: "Charles Knell" <cknell@xxxxxxxxxx>
Date: Fri, 23 Aug 2002 08:27:33 -0700

I'm working on a hierarchical grouping stylesheet, basing my efforts
on Jeni Tennison's "XSLT and XPath on the Edge", Chapter 9. My data set
doesn't have any attributes on which to base grouping, rather I will
base the grouping on the value of a child element (ROW/PERIOD). My first
problem is with this element:

<xsl:variable name="unique-rows" select="..." />

Can anyone explain what the three periods represent? I understand that
a single period represents the context element, and a double period represents
the context element's parent, and in non-XPath ordinary usage, three
periods are an elipsis, representing a continuation of material which
is left out. I can't find any meaning for the three periods in this expression,
and I've looked over and over at the text's example and those three are
definitely there.

Thanks.

Samples of the relevant files:

DATA:

<ROWSET>
   <ROW num="1">
      <MEASUREID>funding</MEASUREID>
      <RVALUE>Green</RVALUE>
      <PERIOD>20021</PERIOD>
   </ROW>
   <ROW num="2">
      <MEASUREID>interfaceControlDocs</MEASUREID>
      <RVALUE>Green</RVALUE>
      <PERIOD>20021</PERIOD>
   </ROW>
   <!-- more ROW elements with child PERIOD elements of value '20021'
here -->
   <!-- note that the value of the PERIOD element changes at this point
-->
   <ROW num="14">
      <MEASUREID>interfaceControlDocs</MEASUREID>
      <RVALUE>Green</RVALUE>
      <PERIOD>20014</PERIOD>
   </ROW>
   <ROW num="15">
      <MEASUREID>LRR</MEASUREID>
      <RVALUE>Green</RVALUE>
      <PERIOD>20014</PERIOD>
   </ROW>
   <!-- more ROW elements -->
</ROWSET>
++++++++++++++++++++++++++++++++++++++++++++++++++
Desired output:

<dataSet project="Manhattan">
  <systemStatus period="20021">
    <measure name="technical" status="Red"></measure>
    <!-- more measures from the '20021' period -->
  </systemStatus>
  <systemStatus period="20021">
    <measure name="technical" status="Red"></measure>
    <!-- more measures from the '20014' period -->
  </systemStatus>
</dataSet>
++++++++++++++++++++++++++++++++++++++++++++++++++
The stylesheet at its present state:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" encoding="UTF-8" />
  <xsl:param name="project" select="'Manhattan'" />
  <xsl:template match="/">
    <xsl:apply-templates>
      <xsl:with-param name="project" />
      </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="ROWSET">
    <xsl:param name="project" />
    <dataSet project="{$project}">
      <xsl:variable name="unique-rows" select="..." />
      <xsl:apply-templates select="$unique-rows" mode="group" />
    </dataSet>
  </xsl:template>

  <xsl:template match="ROW" mode="group">
    <xsl:variable name="wrapper">
      <xsl:apply-templates select="PERIOD" mode="wrapper" />
    </xsl:variable>
    <xsl:variable name="group-items" select="..." />
    <xsl:element name="systemStatus">
      <xsl:apply-templates select="$group-items" mode="item" />
    </xsl:element>
  </xsl:template>

  <xsl:template match="ROW" mode="item">
    <xsl:copy>
      <xsl:copy-of select="@*[local-name() != 'PERIOD']" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

-- 
Charles Knell
cknell@xxxxxxxxxx - email
 

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



Current Thread
Keywords