<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions" xmlns:foa="http://fabio">
  <xsl:import href="TablesAtts.xsl"></xsl:import>
  <xsl:output method="xml" encoding="UTF-8" indent="yes"></xsl:output>
  <xsl:variable name="dots">l</xsl:variable>
  <xsl:variable name="circles">m</xsl:variable>
  <xsl:variable name="squares">n</xsl:variable>
  <xsl:strip-space elements="row"></xsl:strip-space>
  <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master margin-left="1cm" margin-right="1cm" page-width="210mm" margin-bottom="3cm" master-name="myPage" margin-top="2cm" page-height="297mm">
          <fo:region-body ></fo:region-body >
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="mySeq">
          <fo:repeatable-page-master-reference master-reference="myPage"/>
        </fo:page-sequence-master>
      </fo:layout-master-set>
      <fo:page-sequence  master-reference="mySeq">
        <fo:flow  flow-name="xsl-region-body">
          <xsl:apply-templates select="document('Tables.xml')/document"/>
        </fo:flow >
      </fo:page-sequence >
    </fo:root>
  </xsl:template>
  <xsl:template match="document/section/table" foa:name="myTable" foa:class="table" foa:group="complex-table">
    <fo:table foa:name="myTable" foa:group="complex-table" table-layout="fixed" width="453.6pt" xsl:use-attribute-sets=" Table">
      <fo:table-column column-number="1" column-width="6cm"/>
      <fo:table-column column-number="2" column-width="5cm"/>
      <fo:table-column column-number="3" column-width="5cm"/>
      <xsl:apply-templates select="//document/section/table/header"/>
      <xsl:apply-templates select="//document/section/table/footer"/>
      <xsl:apply-templates select="//document/section/table/body"/>
    </fo:table>
  </xsl:template>
  <xsl:template match="document/section/table/body" foa:name="myTable" foa:class="table" foa:group="complex-table" foa:type="table-body">
    <fo:table-body foa:name="myTable" foa:group="complex-table" xsl:use-attribute-sets=" Table">
      <xsl:apply-templates/>
    </fo:table-body>
  </xsl:template>
  <xsl:template match="document/section/table/body/row" foa:name="myTable" foa:class="table-row" foa:group="table-body" foa:type="table-row">
    <fo:table-row foa:name="myTable" foa:group="table-body" xsl:use-attribute-sets=" Row">
      <xsl:apply-templates/>
    </fo:table-row>
  </xsl:template>
  <xsl:template match="document/section/table/body/row/cell" foa:name="myTable" foa:class="table-cell" foa:group="table-body" foa:type="table-cell">
    <fo:table-cell foa:name="myTable" foa:group="table-body" column-number="{position()}" xsl:use-attribute-sets=" Cell">
      <fo:block>
        <xsl:apply-templates/>
        </fo:block>
        </fo:table-cell>
      </xsl:template>
      <xsl:template match="document/section/table/header" foa:name="myTable" foa:class="table" foa:group="complex-table" foa:type="table-header">
        <fo:table-header foa:name="myTable" foa:group="complex-table" xsl:use-attribute-sets=" TableHeader">
          <xsl:apply-templates/>
        </fo:table-header>
      </xsl:template>
      <xsl:template match="document/section/table/header/row" foa:name="myTable" foa:class="table-row" foa:group="table-header" foa:type="table-row">
        <fo:table-row foa:name="myTable" foa:group="table-header" xsl:use-attribute-sets=" Row">
          <xsl:apply-templates/>
        </fo:table-row>
      </xsl:template>
      <xsl:template match="document/section/table/header/row/cell" foa:name="myTable" foa:class="table-cell" foa:group="table-header" foa:type="table-cell">
        <fo:table-cell foa:name="myTable" foa:group="table-header" column-number="{position()}" xsl:use-attribute-sets=" Cell">
          <fo:block>
            <xsl:apply-templates/>
            </fo:block>
            </fo:table-cell>
          </xsl:template>
          <xsl:template match="document/section/table/footer" foa:name="myTable" foa:class="table" foa:group="complex-table" foa:type="table-footer">
            <fo:table-footer foa:name="myTable" foa:group="complex-table" xsl:use-attribute-sets=" TableFooter">
              <xsl:apply-templates/>
            </fo:table-footer>
          </xsl:template>
          <xsl:template match="document/section/table/footer/row" foa:name="myTable" foa:class="table-row" foa:group="table-footer" foa:type="table-row">
            <fo:table-row foa:name="myTable" foa:group="table-footer" xsl:use-attribute-sets=" Row">
              <xsl:apply-templates/>
            </fo:table-row>
          </xsl:template>
          <xsl:template match="document/section/table/footer/row/cell" foa:name="myTable" foa:class="table-cell" foa:group="table-footer" foa:type="table-cell">
            <fo:table-cell foa:name="myTable" foa:group="table-footer" column-number="{position()}" xsl:use-attribute-sets=" Cell">
              <fo:block>
                <xsl:apply-templates/>
                </fo:block>
                </fo:table-cell>
              </xsl:template>
              <xsl:template match="document/section/header" foa:name="Heading" foa:class="block" foa:group="paragraph">
                <fo:block foa:name="Heading" foa:group="paragraph" xsl:use-attribute-sets=" h1">
                  <xsl:apply-templates/>
                </fo:block>
              </xsl:template>
              <xsl:template match="document/section/paragraph" foa:name="Paragraph" foa:class="block" foa:group="paragraph">
                <fo:block foa:name="Paragraph" foa:group="paragraph" xsl:use-attribute-sets=" Normal">
                  <xsl:apply-templates/>
                </fo:block>
              </xsl:template>
            </xsl:stylesheet>
