<?xml version="1.0" encoding="iso-8859-1"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rx="http://www.renderx.com/XSL/Extensions">

  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
           xmlns:dcterms="http://purl.org/dc/terms/"
           xmlns:dc="http://purl.org/dc/elements/1.1/"
           xmlns:db="http://www.oasis-open.org/docbook/xml/4.2/">
     <rdf:Description rdf:about="http://xep.xattic.com/testsuite/features/force-page-count.xml">
        <dc:title>Conditional Page Master</dc:title>
        <dc:description>
          <db:para>
            Demonstrates usage of <db:sgmltag class='attibute'>force-page-count</db:sgmltag> attribute
            to pad the length of page sequences. Also tests conditional page master
            references for blank pages.
          </db:para>
        </dc:description>
        <dc:date>2003-07-25</dc:date><dcterms:requires rdf:resource="http://xep.xattic.com/testsuite/features/macro.xsl"/>
    </rdf:Description>
  </rdf:RDF> 

  <fo:layout-master-set>

    <!-- Page master for the first page -->
    <fo:simple-page-master master-name="first">
      <fo:region-body  margin="1in"
                       display-align="center"
                       padding="6pt 0pt"
                       border-bottom="thin gray groove"/>
      <fo:region-after region-name="first-footer"
                       extent="1in"
                       precedence="true"
                       display-align="before"
                       padding="6pt 1in"/>
    </fo:simple-page-master>

    <!-- Page master for the last page -->
    <fo:simple-page-master master-name="last">
      <fo:region-body  margin="1in"
                       display-align="center"
                       padding="6pt 0pt"
                       border-top="thin gray groove"/>
      <fo:region-before region-name="last-header"
                       extent="1in"
                       display-align="after"
                       precedence="true"
                       padding="6pt 1in"/>
    </fo:simple-page-master>

    <!-- Page master for the rest of the pages -->
    <fo:simple-page-master master-name="rest">
      <fo:region-body  margin="1in"
                       display-align="center"
                       padding="6pt 0pt"
                       border-top="thin gray groove"
                       border-bottom="thin gray groove"/>
      <fo:region-before region-name="rest-header"
                       extent="1in"
                       display-align="after"
                       precedence="true"
                       padding="6pt 1in"/>
      <fo:region-after region-name="rest-footer"
                       extent="1in"
                       precedence="true"
                       display-align="before"
                       padding="6pt 1in"/>
    </fo:simple-page-master>


    <!-- Page master for blank pages -->
    <fo:simple-page-master master-name="blank">
      <fo:region-body  region-name="blank-body"
                       margin="1in"
                       display-align="center"/>
    </fo:simple-page-master>


    <!-- Alternating page sequence master -->
    <fo:page-sequence-master master-name="sequence">
      <fo:repeatable-page-master-alternatives>
        <fo:conditional-page-master-reference 
            master-reference="blank" blank-or-not-blank="blank"/>
        <fo:conditional-page-master-reference 
            master-reference="rest" page-position="rest"/>
        <fo:conditional-page-master-reference 
            master-reference="last" page-position="last"/>
        <fo:conditional-page-master-reference 
            master-reference="first"/>
      </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
  
  </fo:layout-master-set>

  <!-- ============================================================= -->
  <!-- Define a macro for the page sequence. I will need many page   -->
  <!-- sequences of different lengths.                               -->
  <!-- ============================================================= -->

  <define-macro name="lengthy-page-sequence">

    <fo:page-sequence master-reference="sequence" 
                      font="11pt Helvetica" 
                      initial-page-number="$arg1"
                      format="$arg2"
                      force-page-count="$arg3">

      <fo:static-content flow-name="first-footer">
        <fo:block text-align="center">
          Page <fo:page-number/>: this page starts a new page sequence.
        </fo:block>
      </fo:static-content>

      <fo:static-content flow-name="rest-footer">
        <fo:block text-align="center">
          Page <fo:page-number/>: this page continues a page sequence.
        </fo:block>
      </fo:static-content>

      <fo:static-content flow-name="rest-header">
        <fo:block text-align="center">
          Page <fo:page-number/>: this page continues a page sequence.
        </fo:block>
      </fo:static-content>

      <fo:static-content flow-name="last-header">
        <fo:block text-align="center">
          Page <fo:page-number/>: this page is the last in a page sequence.
        </fo:block>
      </fo:static-content>

      <fo:static-content flow-name="blank-body">
        <fo:block text-align="center">
          Page <fo:page-number/>: this page is intentionally left blank.
        </fo:block>
      </fo:static-content>

      <fo:flow flow-name="xsl-region-body" font="13pt Times">
        <repeat times="$arg">
          <p space-before="9pt" space-after="9pt">
            This test contains several lengthy page sequences. All page 
            sequences use the same page sequence master. Pages should be
            formatted as follows:
          </p>
          <ul space-before="9pt" space-after="9pt">
            <li>the first page in each sequence should have a footer;</li>
            <li>the last page in each sequence should have a header;</li>
            <li>blank pages should have neither header nor footer;</li>
            <li>other pages should have both a header and a footer.</li>
          </ul>
          <p space-before="9pt" space-after="9pt">
            This particular page sequence instance is formatted using 
            the following attributes:
          </p>
          <ul space-before="9pt" space-after="9pt" font-family="monospace">
            <li>initial-page-number=&quot;<arg1/>&quot;</li>
            <li>format=&quot;<arg2/>&quot;</li>
            <li>force-page-count=&quot;<arg3/>&quot;</li>
          </ul>

        </repeat> 
      </fo:flow>

    </fo:page-sequence>
  </define-macro>

  <macro name="lengthy-page-sequence" arg="10" arg1="1" arg2="1" arg3="auto"/>
  <macro name="lengthy-page-sequence" arg="3" arg1="auto" arg2="I" arg3="end-on-odd"/>
  <macro name="lengthy-page-sequence" arg="8" arg1="auto-odd" arg2="i" arg3="end-on-even"/>
  <macro name="lengthy-page-sequence" arg="16" arg1="auto-even" arg2="a" arg3="even"/>
  <macro name="lengthy-page-sequence" arg="4" arg1="auto-odd" arg2="A" arg3="odd"/>
  <macro name="lengthy-page-sequence" arg="7" arg1="auto" arg2="[1]" arg3="no-force"/>
  <macro name="lengthy-page-sequence" arg="20" arg1="888" arg2="[I]" arg3="auto"/>
  <macro name="lengthy-page-sequence" arg="5" arg1="auto-odd" arg2="[i]" arg3="auto"/>
  <macro name="lengthy-page-sequence" arg="1" arg1="auto-even" arg2="[a]" arg3="auto"/>
  <macro name="lengthy-page-sequence" arg="1" arg1="auto-even" arg2="[A]" arg3="even"/>
  <macro name="lengthy-page-sequence" arg="4" arg1="1" arg2="(1)" arg3="auto"/>
  <macro name="lengthy-page-sequence" arg="8" arg1="48" arg2="(I)" arg3="odd"/>
  <macro name="lengthy-page-sequence" arg="2" arg1="auto" arg2="(i)" arg3="end-on-odd"/>
  <macro name="lengthy-page-sequence" arg="12" arg1="auto-odd" arg2="(A)" arg3="end-on-odd"/>
  <macro name="lengthy-page-sequence" arg="6" arg1="auto-even" arg2="(a)" arg3="auto"/>
</fo:root>
