<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="xsl-atts/DocsAtts.xsl"></xsl:import>
  <xsl:output method="xml" encoding="UTF-8"></xsl:output>
  <xsl:variable name="dots">l</xsl:variable>
  <xsl:variable name="circles">m</xsl:variable>
  <xsl:variable name="squares">n</xsl:variable>
  <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master margin-left="2cm" margin-right="2cm" page-width="210mm" margin-bottom="3cm" master-name="pagina" margin-top="2cm" page-height="297mm">
          <fo:region-after extent="1cm"></fo:region-after>
          <fo:region-body  margin-bottom="1.5cm" margin-top="2cm"></fo:region-body >
          <fo:region-before extent="2cm"></fo:region-before>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="documentation">
          <fo:repeatable-page-master-reference master-reference="pagina"/>
        </fo:page-sequence-master>
      </fo:layout-master-set>
      <fo:page-sequence  master-reference="documentation">
        <fo:static-content flow-name="xsl-region-before">
        </fo:static-content>
        <fo:static-content flow-name="xsl-region-after">
          <xsl:apply-templates select="document('fop-docs/fop.xml')/book"/>
        </fo:static-content>
        <fo:flow  flow-name="xsl-region-body">
          <xsl:apply-templates select="document('fop-docs/readme.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/todo.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/download.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/running.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/implemented.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/limitations.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/examples.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/configuration.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/fonts.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/extensions.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/svg.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/compiling.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/embedding.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/testing.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/involved.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/architecture.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/bugs.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/faq.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/resources.xml')/s1"/>
          <xsl:apply-templates select="document('fop-docs/license.xml')/s1"/>
        </fo:flow >
      </fo:page-sequence >
    </fo:root>
  </xsl:template>
  <xsl:template match="//jump" foa:name="ExtLink" foa:class="inline" foa:group="ext-link">
    <fo:basic-link foa:name="ExtLink" foa:group="ext-link" external-destination="{@href}" xsl:use-attribute-sets=" link">
      <xsl:apply-templates/>
    </fo:basic-link>
  </xsl:template>
  <xsl:template match="//code" foa:name="Code" foa:class="inline" foa:group="emphasis">
    <fo:inline foa:name="Code" foa:group="emphasis" xsl:use-attribute-sets=" code">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>
  <xsl:template match="//em" foa:name="Emph" foa:class="inline" foa:group="emphasis">
    <fo:inline foa:name="Emph" foa:group="emphasis" xsl:use-attribute-sets=" bold_1">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>
  <xsl:template match="//ol" foa:name="OrdList" foa:class="list" foa:group="list">
    <fo:list-block foa:name="OrdList" foa:group="list" xsl:use-attribute-sets=" list">
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template>
  <xsl:template match="//ol/li" foa:name="OrdList" foa:class="list" foa:group="list" foa:type="ord-list-item">
    <fo:list-item foa:name="OrdList" foa:group="list">
      <fo:list-item-label foa:name="OrdList" foa:group="list" end-indent="label-end()">
        <fo:block foa:name="OrdList" foa:group="list" xsl:use-attribute-sets=" Text">
          <xsl:number format="1."/>
        </fo:block>
      </fo:list-item-label>
      <fo:list-item-body foa:name="OrdList" foa:group="list" start-indent="body-start()">
        <fo:block foa:name="OrdList" foa:group="list" xsl:use-attribute-sets=" Text">
          <xsl:apply-templates/>
        </fo:block>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template>
  <xsl:template match="//dl" foa:name="LabelBd" foa:class="list" foa:group="list">
    <fo:list-block foa:name="LabelBd" foa:group="list" xsl:use-attribute-sets=" list">
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template>
  <xsl:template match="//dl/dt" foa:name="LabelBd" foa:class="list" foa:group="list" foa:type="item-label">
    <xsl:text disable-output-escaping="yes"><![CDATA[<fo:list-item foa:name="LabelBd" foa:group="list">]]></xsl:text>
    <fo:list-item-label foa:name="LabelBd" foa:group="list" end-indent="label-end()">
      <fo:block foa:name="LabelBd" foa:group="list" xsl:use-attribute-sets="Text">
        <xsl:apply-templates/>
      </fo:block>
    </fo:list-item-label>
  </xsl:template>
  <xsl:template match="//dl/dd" foa:name="LabelBd" foa:class="list" foa:group="list" foa:type="item-body">
    <fo:list-item-body foa:name="LabelBd" foa:group="list" start-indent="body-start()">
      <fo:block foa:name="LabelBd" foa:group="list" xsl:use-attribute-sets=" Text">
        <xsl:apply-templates/>
      </fo:block>
    </fo:list-item-body>
    <xsl:text disable-output-escaping="yes"><![CDATA[</fo:list-item>]]></xsl:text>
  </xsl:template>
  <xsl:template match="//ul" foa:name="Dotted" foa:class="list" foa:group="list">
    <fo:list-block foa:name="Dotted" foa:group="list" xsl:use-attribute-sets=" list">
      <xsl:apply-templates/>
    </fo:list-block>
  </xsl:template>
  <xsl:template match="//ul/li" foa:name="Dotted" foa:class="list" foa:group="list" foa:type="unord-list-item">
    <fo:list-item foa:name="Dotted" foa:group="list">
      <fo:list-item-label foa:name="Dotted" foa:group="list" end-indent="label-end()">
        <fo:block foa:name="Dotted" foa:group="list" font-family="ZapfDingbats" font-size="0.6em" font-weight="normal" font-style="normal" color="black">
          <xsl:value-of select="$dots"/>
        </fo:block>
      </fo:list-item-label>
      <fo:list-item-body foa:name="Dotted" foa:group="list" start-indent="body-start()">
        <fo:block foa:name="Dotted" foa:group="list" xsl:use-attribute-sets=" Text">
          <xsl:apply-templates/>
        </fo:block>
      </fo:list-item-body>
    </fo:list-item>
  </xsl:template>
  <xsl:template match="//s4" foa:name="T4" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="T4" foa:group="paragraph" xsl:use-attribute-sets=" h4">
      <xsl:value-of select="@title"/>
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//s3" foa:name="T3" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="T3" foa:group="paragraph" xsl:use-attribute-sets=" h3">
      <xsl:value-of select="@title"/>
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//source" foa:name="Source" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="Source" foa:group="paragraph" xsl:use-attribute-sets=" Source">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//p" foa:name="Text" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="Text" foa:group="paragraph" xsl:use-attribute-sets=" Text">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="s1/s2" foa:name="T2" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="T2" foa:group="paragraph" xsl:use-attribute-sets=" h2">
      <xsl:value-of select="@title"/>
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//s1" foa:name="T1" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="T1" foa:group="paragraph" xsl:use-attribute-sets=" h1">
      <xsl:value-of select="@title"/>
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
  <xsl:template match="//book[@copyright='1999-2001 The Apache Software Foundation']" foa:name="BookCopyright" foa:class="block" foa:group="paragraph">
    <fo:block foa:name="BookCopyright" foa:group="paragraph" xsl:use-attribute-sets=" Copyright">
      <xsl:value-of select="@copyright"/>
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>
</xsl:stylesheet>
