<?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: fox_external-document_2.xml 1531769 2013-10-13 23:31:46Z lbernardo $ -->
<testcase>
  <info>
    <p>
      This test checks fox:external-document.
    </p>
  </info>
  <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
        xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
          <fo:region-body reference-orientation="90"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fox:external-document id="img1" src="../resources/images/bgimg72dpi.png"
        width="5in" height="5in" text-align="center" display-align="center"/>
      <fo:page-sequence master-reference="normal" id="ps1">
        <fo:flow flow-name="xsl-region-body">
          <fo:block>
            Just a normal page-sequence in between...
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
      <fox:external-document id="img2" src="../resources/images/bgimg72dpi.png"
        width="5in" height="5in" content-width="scale-to-fit"/>
      <fox:external-document id="img3" src="../resources/images/bgimg72dpi.png"
        width="5in" height="5in" content-width="scale-down-to-fit" initial-page-number="5"/>
      <fox:external-document id="img4" src="../resources/images/big-image.png"
        reference-orientation="90"/>
    </fo:root>
  </fo>
  <checks>
    <eval expected="5" xpath="count(/areaTree/pageSequence)"/>
    <eval expected="6" xpath="count(//pageViewport)"/>
    
    <eval expected="1" xpath="//pageViewport[@nr = '1']/@formatted-nr"/>
    <eval expected="2" xpath="//pageViewport[@nr = '2']/@formatted-nr"/>
    <eval expected="3" xpath="//pageViewport[@nr = '3']/@formatted-nr"/>
    <eval expected="4" xpath="//pageViewport[@nr = '4']/@formatted-nr"/>
    <true xpath="boolean(//pageViewport[@nr = '4']/@blank)"/> <!-- effect from force-page-count="auto" -->
    <eval expected="5" xpath="//pageViewport[@nr = '5']/@formatted-nr"/>
    <eval expected="6" xpath="//pageViewport[@nr = '6']/@formatted-nr"/>
    
    <eval expected="0 0 360000 360000" xpath="//pageViewport[@nr = '1']/@bounds"/>
    <eval expected="0 0 360000 360000" xpath="//pageViewport[@nr = '2']/@bounds"/>
    <eval expected="0 0 360000 360000" xpath="//pageViewport[@nr = '3']/@bounds"/>
    <eval expected="0 0 360000 360000" xpath="//pageViewport[@nr = '5']/@bounds"/>
    <eval expected="0 0 843913 597172" xpath="//pageViewport[@nr = '6']/@bounds"/>
    
    <eval expected="84012 84012 191976 191976" xpath="//viewport[@prod-id = 'img1']/@pos"/>
    <eval expected="0 0 360000 360000" xpath="//viewport[@prod-id = 'img2']/@pos"/>
    <eval expected="0 0 191976 191976" xpath="//viewport[@prod-id = 'img3']/@pos"/>
    <eval expected="0 0 597172 843913" xpath="//viewport[@prod-id = 'img4']/@pos"/>

    <eval expected="0 0 843913 597172" xpath="//pageViewport[@nr = '6']/page/regionViewport/@rect"/>
    <eval expected="597172" xpath="//pageViewport[@nr = '6']/page/regionViewport/@ipd"/>
    <eval expected="843913" xpath="//pageViewport[@nr = '6']/page/regionViewport/@bpd"/>
    <eval expected="597172" xpath="//pageViewport[@nr = '6']/page/regionViewport/regionBody/@ipd"/>
    <eval expected="843913" xpath="//pageViewport[@nr = '6']/page/regionViewport/regionBody/@bpd"/>
    <eval expected="[0.0 -1.0 1.0 0.0 0.0 597172.0]" xpath="//pageViewport[@nr = '6']/page/regionViewport/regionBody/@ctm"/>
    
  </checks>
</testcase>
