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

trying to test for last page with xsl:choose

Expand Messages
  • freefly_xml
    I want to test to see if I am on the last page of a document. In this example it is an invoice. I want to print a different table in REGION AFTER when I am on
    Message 1 of 3 , May 15, 2006
      I want to test to see if I am on the last page of a document. In
      this example it is an invoice. I want to print a different table in
      REGION AFTER when I am on the last page. I have tried many
      variations, no luck yet. It seems like it should be an easy thing to
      do with xsl:choose.

      Any ideas? Here is one of my attempts.
      More detail of what the xml, xsl and pdf look like are here:
      http://www.bangboompow.com/xml/invoice/


      I am trying to test the field value in the footer area like this:

      <xsl:choose>
      <xsl:when test="document_end = 'TRUE'">
      <fo:block font-size="10pt" font-weight="bold">
      LAST PAGE
      </fo:block>
      </xsl:when>
      <xsl:otherwise>
      <fo:block font-size="10pt" font-weight="bold">
      not the last page
      </fo:block>
      </xsl:otherwise>
      </xsl:choose>

      I am trying to set the value of the field in the detail line loop
      like this:

      <xsl:if test="position() = last()">
      <xsl:variable name="document_end" select="'TRUE'" />
      </xsl:if>
    • G. Ken Holman
      ... This test is not available in XSLT because it is only known to the XSL-FO engine. ... Then use a page subsequence when you are describing patterns of your
      Message 2 of 3 , May 15, 2006
        At 2006-05-15 22:04 +0000, freefly_xml wrote:
        >I want to test to see if I am on the last page of a document.

        This test is not available in XSLT because it is only known to the
        XSL-FO engine.

        >In this example it is an invoice. I want to print a different table in
        >REGION AFTER when I am on the last page.

        Then use a page subsequence when you are describing patterns of your
        page geometry.

        >I have tried many
        >variations, no luck yet. It seems like it should be an easy thing to
        >do with xsl:choose.

        Not at all ... xsl:choose is part of XSLT and all of XSLT processing
        is complete before the XSL-FO engine even sees any of the results of
        the transformation. It is a two-step styling process: an XSLT engine
        rearranges your information and constructs the XSL-FO you need, then
        an XSL-FO engine takes the transformed results and renders it.

        >Any ideas?

        Either one of the following should help you:

        (1) Use the <footnote> construct at the end of the flow so that the
        formatter drops your table to the bottom of the main reference area
        and above the after region; or

        (2) Use a pattern of page geometries where you test
        page-position="last" and utilize a page geometry where you've flowed
        your table into the after region of the static content of the page
        master you've triggered for the last page.

        >Here is one of my attempts.
        >More detail of what the xml, xsl and pdf look like are here:
        >http://www.bangboompow.com/xml/invoice/

        On our web site in the "Free resources" section you can download free
        XSLT/XSL-FO invoice stylesheets (as well as for 7 other document
        types) for instances of the Universal Business Language. The
        following was produced with those free stylesheets:

        http://docs.oasis-open.org/ubl/cd-UBL-1.0/fs/Invoice/pdf/UN380Invoice.Example-us.pdf

        >I am trying to test the field value in the footer area like this:
        >
        ><xsl:choose>
        > <xsl:when test="document_end = 'TRUE'">
        > <fo:block font-size="10pt" font-weight="bold">
        > LAST PAGE
        > </fo:block>
        > </xsl:when>
        > <xsl:otherwise>
        > <fo:block font-size="10pt" font-weight="bold">
        > not the last page
        > </fo:block>
        > </xsl:otherwise>
        ></xsl:choose>

        The above is not possible because there is no feedback loop from an
        active formatting process back to the transformation that created the XSL-FO.

        >I am trying to set the value of the field in the detail line loop
        >like this:
        >
        ><xsl:if test="position() = last()">
        > <xsl:variable name="document_end" select="'TRUE'" />
        ></xsl:if>

        The above would never help you because the scope of a variable is
        only the following siblings and their descendants after the variable
        declaration, and you do not have any siblings after the variable declaration.

        I hope this helps.

        . . . . . . . . . Ken

        --
        Registration open for XSLT/XSL-FO training: Wash.,DC 2006-06-12/16
        Also for XSLT/XSL-FO training: Minneapolis, MN 2006-07-31/08-04
        Also for XML/XSLT/XSL-FO training: Varo, Denmark 2006-09-25/10-05
        World-wide on-site corporate, govt. & user group XML/XSL training.
        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
        Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/f/bc
        Legal business disclaimers: http://www.CraneSoftwrights.com/legal
      • freefly_xml
        A working way to create a different footer for the last page of a document with xslt. In the looping of the detail lines test for the last line and set a
        Message 3 of 3 , May 16, 2006
          A working way to create a different footer for the last page of a
          document with xslt.

          In the looping of the detail lines test for the last line and set a
          marker:

          <xsl:choose>
          <xsl:when test="position() = last()">
          <fo:marker marker-class-name="footer-marker">
          <fo:block>LAST PAGE</fo:block>
          </fo:marker>
          </xsl:when>
          <xsl:otherwise>
          <fo:marker marker-class-name="footer-marker">
          <fo:block>Continued...</fo:block>
          </fo:marker>
          </xsl:otherwise>
          </xsl:choose>

          then retrieve the marker in the region-after with this:

          <fo:retrieve-marker retrieve-position="last-ending-within-page"
          retrieve-class-name="footer-marker" />

          more details:
          http://www.bangboompow.com/xml/invoice
        Your message has been successfully submitted and would be delivered to recipients shortly.