[xsl] Grouping by an attribute of a child

Subject: [xsl] Grouping by an attribute of a child
From: David Christiansen <DavidCh@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Apr 2003 11:12:43 -0600
Hi,

I am trying to group records together so I can do subtotaling and page
breaks.  I need to do this when the element "Attribute" with Attribute
"Railcar Number" has the attribute "Value" changes (Sample XML below)  Not
all records will have an element "Attribute" with a name "Railcar Number"
(if that has anything to do with anything)

By the time I enter the "Activity" template, I have already done sorting by
Railcar Number, then Activity Date.  At the first of this, I do check to see
if I am on the first record to prevent doing a page break at this point.
This part seems to work.  The second test is one of the many attempts that I
have tried without success.

If there is anyone with some help, I would appreciate this.

Thanks,

David Christiansen


Fragments of xsl and xml files:


-----XSL-----
  <xsl:template match="Invoices/Invoice/Activity">
    <xsl:if test="position()!=1">
        <xsl:if test="Attribute[@Name='Railcar
Number']/Value=preceding-sibling::*[1]/Attribute[@Name='Railcar
Number']/Value">
          <fo:block font-size="10.0pt" font-family="serif"
text-align="start">
            page break
          </fo:block>
        </xsl:if>
      </fo:table-row>
    </xsl:if>
    <xsl:apply-templates select="Revenue"/>
  </xsl:template>


-----XML-----
<Invoices>
  <Invoice>
    <Activity>
      <ActivityDate>
        04/07/2003
      </ActivityDate>
      <Attribute ID="562386" Name="Dollars" Value="232">
      </Attribute>
      <Attribute ID="562387" Name="Description" Value="Charge">
      </Attribute>
    </Activity>
    <Activity>
      <ActivityDate>
        04/05/2003
      </ActivityDate>
      <Attribute ID="562406" Name="Railcar Number" Value="ZXCV">
      </Attribute>
      <Attribute ID="562407" Name="Bill Of Lading" Value="AAA">
      </Attribute>
    </Activity>
    <Activity>
      <ActivityDate>
        04/04/2002
      </ActivityDate>
      <Attribute ID="562416" Name="Hours" Value="2">
      </Attribute>
      <Attribute ID="562417" Name="Audit Number" Value="123">
      </Attribute>
      <Attribute ID="562418" Name="Railcar Number" Value="ZXCV">
      </Attribute>
    </Activity>
    <Activity>
      <ActivityDate>
        04/07/2002
      </ActivityDate>
      <Attribute ID="562427" Name="Hours" Value="3">
      </Attribute>
      <Attribute ID="562428" Name="Railcar Number" Value="QWERT">
      </Attribute>
    </Activity>
    <Activity>
      <ActivityDate>
        04/06/2003
      </ActivityDate>
      <Attribute ID="562429" Name="Dollars" Value="150">
      </Attribute>
      <Attribute ID="562430" Name="Railcar Number" Value="QWERT">
      </Attribute>
    </Activity>
  </Invoice>
</Invoices>

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


Current Thread