<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- $Id$ -->
<testcase>
    <info>
        <p>This test checks links to and from the last page.</p>
    </info>
    <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master margin="2cm" master-name="odd" page-height="297mm" page-width="210mm">
          <fo:region-body column-count="2" column-gap="28pt"/>
        </fo:simple-page-master>
        <fo:simple-page-master margin="2cm" master-name="even" page-height="297mm" page-width="210mm">
          <fo:region-body column-count="2" column-gap="28pt"/>
        </fo:simple-page-master>
        <fo:simple-page-master margin="2cm" master-name="last" page-height="297mm" page-width="210mm">
          <fo:region-body column-count="2" column-gap="28pt"/>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="basicPSM">
          <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="last" odd-or-even="any" page-position="last"/>
            <fo:conditional-page-master-reference master-reference="odd" odd-or-even="odd" page-position="any"/>
            <fo:conditional-page-master-reference master-reference="even" odd-or-even="even" page-position="any"/>
          </fo:repeatable-page-master-alternatives>
        </fo:page-sequence-master>
      </fo:layout-master-set>
      <fo:bookmark-tree>
        <fo:bookmark internal-destination="title" starting-state="show">
          <fo:bookmark-title>title</fo:bookmark-title>
        </fo:bookmark>
      </fo:bookmark-tree>
      <fo:page-sequence id="lastpagesequence" master-reference="basicPSM">
        <fo:flow flow-name="xsl-region-body">
          <fo:block id="par" break-after="page">par</fo:block>
          <fo:block id="par2" break-after="page">par2</fo:block>
          <fo:block id="par3" break-after="page">par3</fo:block>
          <fo:block>before-title</fo:block>
          <fo:block id="title" keep-with-next="always">title</fo:block>
          <fo:block>
            <fo:basic-link internal-destination="par2">
              siehe  <fo:inline keep-together="always">
                Seite <fo:page-number-citation ref-id="par2"/>
              </fo:inline>
            </fo:basic-link>
          </fo:block>
          <fo:block break-before="column">title2</fo:block>
          <fo:block>
            <fo:basic-link internal-destination="par3">
              siehe  <fo:inline keep-together="always">
                Seite <fo:page-number-citation ref-id="par3"/>
              </fo:inline>
            </fo:basic-link>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
    </fo>
    <checks>
        <eval expected="(P2,par2)" xpath="((/areaTree/pageSequence/pageViewport)[4]//inlineparent[@internal-link])[1]/@internal-link"/>
        <eval expected="(P3,par3)" xpath="((/areaTree/pageSequence/pageViewport)[4]//inlineparent[@internal-link])[2]/@internal-link"/>
        <eval expected="(P6,title)" xpath="/areaTree/bookmarkTree/bookmark/@internal-link"/>
        <eval expected="4" xpath="count(/areaTree/pageSequence/pageViewport)"/>
    </checks>
</testcase>
