Mirko Sertic wrote:
Hello!

Yes, i need a partial sum. How would this be done using markers ?
Is there an example available ?

Try ----------- XML --------------- <?xml version="1.0"?> <elements> <element> <name>prod 1</name><price>10.0</price> </element> <element> <name>prod 2</name><price>5.0</price> </element> <element> <name>prod 3</name><price>2.0</price> </element> <element> <name>prod 4</name><price>1.1</price> </element> <element> <name>prod 5</name><price>3.4</price> </element> <element> <name>prod 6</name><price>5.9</price> </element> <element> <name>prod 7</name><price>4.88</price> </element> <element> <name>prod 8</name><price>20.04</price> </element> </elements>

----------- XSL ---------------
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:fo="http://www.w3.org/1999/XSL/Format";>

  <xsl:strip-space elements="*"/>

  <xsl:template match="elements">
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simple"
          page-width="6cm" page-height="5cm">
          <fo:region-body margin-bottom="2cm"/>
          <fo:region-after extent="2cm"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simple" font-size="24pt">
        <fo:static-content flow-name="xsl-region-after">
          <fo:table table-layout="fixed" width="100%">
            <fo:table-column column-width="3cm"/>
            <fo:table-column column-width="3cm"/>
            <fo:table-body>
              <fo:table-row>
                <fo:table-cell border-before-style="solid"
                  border-before-width="2pt">
                  <fo:block>
                    <fo:retrieve-marker retrieve-class-name="subtotalname"
                      retrieve-boundary="page"
                      retrieve-position="last-starting-within-page"/>
                  </fo:block>
                </fo:table-cell>
                <fo:table-cell border-before-style="solid"
                  border-before-width="2pt">
                  <fo:block text-align-last="end">
                    <fo:retrieve-marker retrieve-class-name="subtotalvalue"
                      retrieve-boundary="page"
                      retrieve-position="last-starting-within-page"/>
                  </fo:block>
                </fo:table-cell>
              </fo:table-row>
            </fo:table-body>
          </fo:table>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <fo:table table-layout="fixed" width="100%">
            <fo:table-column column-width="3cm"/>
            <fo:table-column column-width="3cm"/>
            <fo:table-body>
              <xsl:apply-templates select="element"/>
            </fo:table-body>
          </fo:table>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>

  <xsl:template match="element">
    <fo:table-row>
      <fo:table-cell>
        <fo:block>
          <fo:marker marker-class-name="subtotalname">
            <xsl:choose>
              <xsl:when test="position()=last()">
                <xsl:text>total</xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text>subtotal</xsl:text>
              </xsl:otherwise>
            </xsl:choose>
          </fo:marker>
          <fo:marker marker-class-name="subtotalvalue">
            <xsl:value-of select="price + sum(preceding::price)"/>
          </fo:marker>
          <xsl:value-of select="name"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block text-align-last="end">
          <xsl:value-of select="price"/>
        </fo:block>
      </fo:table-cell>
    </fo:table-row>
  </xsl:template>

</xsl:stylesheet>

No, you can't have subtotals *per page*, only cumulated subtotals.

J.Pietschmann


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to