Loading ...
Sorry, an error occurred while loading the content.
 

page numbering - restarting by xml node, footer citation

Expand Messages
  • yah_hal_00 <mpartridge@mn.rr.com>
    I ve seen a few posts regarding this issue, but haven t been able to figure out my own case. I m very new to xslt & xsl:fo, so I may be confused as to how this
    Message 1 of 2 , Mar 4, 2003
      I've seen a few posts regarding this issue, but haven't been able to
      figure out my own case. I'm very new to xslt & xsl:fo, so I may be
      confused as to how this all works. I should also say that I'm using an
      xsl stylesheet w/ xsl:fo inside templates and transforming to pdf
      using FOP. My problems are summarized in the subject - I need to
      restart page numbering for each <invoice> node below, and have the
      page footer for each page of an <invoice> say the current page number
      and total pages for the current <invoice>.

      Here's what my xml file looks like:

      <invoice-set>
      <invoice>
      <name>Firstname Lastname</name>
      <inv_id>12</inv_id>
      <total>200.00</total>
      <detail>
      <item>1101001</item>
      <item>1001001</item>
      <item>1000100</item>
      <item>1111111</item>
      </detail>
      </invoice>
      <invoice>
      <name>Firstname2 Lastname2</name>
      <inv_id>13</inv_id>
      <total>100.00</total>
      <detail>
      <item>1101001</item>
      <item>1001001</item>
      </detail>
      </invoice>
      </invoice-set>

      I know I need to start a new page-sequence for each <invoice> node,
      but I must be doing something wrong. Snippets of xsl:

      <xsl:template match="/">

      <fo:root>
      <fo:layout-master-set>
      ...
      </fo:layout-master-set>

      <fo:page-sequence
      initial-page-number="1"
      master-reference="only">

      <fo:static-content flow-name="xsl-region-after">
      <xsl:call-template name="page-footer"/>
      </fo:static-content>

      <fo:flow flow-name="xsl-region-body">
      <!--try to apply templates from the xml file -->
      <xsl:apply-templates/>
      <!-- set last page marker -->
      <fo:block id="last-page"/>
      </fo:flow>
      </fo:page-sequence>

      My layout-master-set has one simple-page-master, "only", which defines
      xsl-region-bodyand and xsl-region-after. After closing the <fo:root>
      and <xsl:template match="/">, I have my invoice template, which is
      pretty simple:

      <xsl:template match="invoice">
      <!-- this causes a page break for each invoice -->
      <fo:block break-before="page">

      <xsl:call-template name="pay-stub" />
      <xsl:call-template name="body" />

      <fo:block id="{generate-id()}"/>
      </fo:block>
      </xsl:template>

      After the pay-stub and body templates, I've got page-footer defined:

      <xsl:template name="page-footer">
      <fo:block text-align-last="center">
      Page <fo:page-number/> of
      <fo:page-number-citation ref-id="{generate-id()}"/>
      </fo:block>
      </xsl:template>

      I decided to use generate-id() thanks to narinder_g, but they said if
      the two were in different templates (which they are in my case), the
      node needs to be passed in. I'm not sure how this is done. I've tried
      generate-id(.), generate-id(/invoice-set/invoice),
      generate-id(./invoice), and all give errors. Either it can't find the
      ref-id attribute in my page-number-citation or it the
      page-number-citation comes out blank as in the case above. Any help
      would be greatly appreciated.

      Mike
    • yah_hal_00 <mpartridge@mn.rr.com>
      Figured it out. If anyone is interested, I had to move the page-sequence to the like so: fixed xsl snippet
      Message 2 of 2 , Mar 4, 2003
        Figured it out. If anyone is interested, I had to move the
        page-sequence to the <xsl:template match="invoice"> like so:

        fixed xsl snippet

        <!-- took the page sequence which was surrounding the
        xsl:apply-templates/ and moved it -->

        <xsl:template match="/">
        <fo:root>
        <fo:layout-master-set>
        ...
        </fo:layout-master-set>

        <!--try to apply templates from the xml file -->
        <xsl:apply-templates/>

        </fo:root>
        </xsl:template>

        <!-- to the invoice template -->

        <xsl:template match="invoice">

        <fo:page-sequence initial-page-number="1" master-reference="only">

        <fo:static-content flow-name="xsl-region-after">
        <xsl:call-template name="page-footer"/>
        </fo:static-content>

        <fo:flow flow-name="xsl-region-body">

        <!-- this causes a page break for each invoice -->
        <fo:block break-before="page">

        <xsl:call-template name="pay-stub" />
        <xsl:call-template name="body" />

        <fo:block id="{generate-id()}"/>

        </fo:block>
        </fo:flow>
        </fo:page-sequence>

        </xsl:template>

        Thanks also to G Ken Holman, who provided information that helped.

        --- In XSL-FO@yahoogroups.com, "yah_hal_00 <mpartridge@m...>"
        <mpartridge@m...> wrote:
        > I've seen a few posts regarding this issue, but haven't been able to
        > figure out my own case. I'm very new to xslt & xsl:fo, so I may be
        > confused as to how this all works. I should also say that I'm using an
        > xsl stylesheet w/ xsl:fo inside templates and transforming to pdf
        > using FOP. My problems are summarized in the subject - I need to
        > restart page numbering for each <invoice> node below, and have the
        > page footer for each page of an <invoice> say the current page number
        > and total pages for the current <invoice>.
        >
        > Here's what my xml file looks like:
        >
        > <invoice-set>
        > <invoice>
        > <name>Firstname Lastname</name>
        > <inv_id>12</inv_id>
        > <total>200.00</total>
        > <detail>
        > <item>1101001</item>
        > <item>1001001</item>
        > <item>1000100</item>
        > <item>1111111</item>
        > </detail>
        > </invoice>
        > <invoice>
        > <name>Firstname2 Lastname2</name>
        > <inv_id>13</inv_id>
        > <total>100.00</total>
        > <detail>
        > <item>1101001</item>
        > <item>1001001</item>
        > </detail>
        > </invoice>
        > </invoice-set>
        >
        > I know I need to start a new page-sequence for each <invoice> node,
        > but I must be doing something wrong. Snippets of xsl:
        >
        > <xsl:template match="/">
        >
        > <fo:root>
        > <fo:layout-master-set>
        > ...
        > </fo:layout-master-set>
        >
        > <fo:page-sequence
        > initial-page-number="1"
        > master-reference="only">
        >
        > <fo:static-content flow-name="xsl-region-after">
        > <xsl:call-template name="page-footer"/>
        > </fo:static-content>
        >
        > <fo:flow flow-name="xsl-region-body">
        > <!--try to apply templates from the xml file -->
        > <xsl:apply-templates/>
        > <!-- set last page marker -->
        > <fo:block id="last-page"/>
        > </fo:flow>
        > </fo:page-sequence>
        >
        > My layout-master-set has one simple-page-master, "only", which defines
        > xsl-region-bodyand and xsl-region-after. After closing the <fo:root>
        > and <xsl:template match="/">, I have my invoice template, which is
        > pretty simple:
        >
        > <xsl:template match="invoice">
        > <!-- this causes a page break for each invoice -->
        > <fo:block break-before="page">
        >
        > <xsl:call-template name="pay-stub" />
        > <xsl:call-template name="body" />
        >
        > <fo:block id="{generate-id()}"/>
        > </fo:block>
        > </xsl:template>
        >
        > After the pay-stub and body templates, I've got page-footer defined:
        >
        > <xsl:template name="page-footer">
        > <fo:block text-align-last="center">
        > Page <fo:page-number/> of
        > <fo:page-number-citation ref-id="{generate-id()}"/>
        > </fo:block>
        > </xsl:template>
        >
        > I decided to use generate-id() thanks to narinder_g, but they said if
        > the two were in different templates (which they are in my case), the
        > node needs to be passed in. I'm not sure how this is done. I've tried
        > generate-id(.), generate-id(/invoice-set/invoice),
        > generate-id(./invoice), and all give errors. Either it can't find the
        > ref-id attribute in my page-number-citation or it the
        > page-number-citation comes out blank as in the case above. Any help
        > would be greatly appreciated.
        >
        > Mike
      Your message has been successfully submitted and would be delivered to recipients shortly.