<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                version="1.0">

<!--
Named template to generate a short message in the PDF footer, from text in
skinconf.xml.  By default, the message is a copyright statement.  If a credit
with @role='pdf' is present, that is used instead.  Eg:

<credit role="pdf">
  <name>Generated by Apache FOP 1.0-dev</name>
  <url>http://xml.apache.org/forrest/fop/dev/</url>
</credit>
-->

  <xsl:param name="config-file" select="'../../../../skinconf.xml'"/>
  <xsl:variable name="config" select="document($config-file)/skinconfig"/>

  <xsl:template name="info">
    <xsl:variable name="pdfcredit" select="$config/credits/credit[@role = 'pdf']"/>
    <xsl:variable name="text">
      <xsl:if test="$pdfcredit">
        <xsl:value-of select="$pdfcredit/name"/>
      </xsl:if>
      <xsl:if test="not($pdfcredit)">
        <xsl:text>Copyright &#169; </xsl:text><xsl:value-of select="$config/year"/>&#160;<xsl:value-of
          select="$config/vendor"/><xsl:text> All rights reserved.</xsl:text>
      </xsl:if>
    </xsl:variable>
    <xsl:variable name="url" select="$pdfcredit/url"/>

    <fo:block-container font-style="italic" absolute-position="absolute"
      left="0pt" top="0pt" right="6.25in" bottom="150pt"
      font-size="10pt">
      <xsl:if test="not($url)">
        <fo:block text-align="center" color="lightgrey">
          <xsl:value-of select="$text"/>
        </fo:block>
      </xsl:if>
      <xsl:if test="$url">
        <fo:block text-align="center">
          <fo:basic-link color="lightgrey"
            external-destination="{$url}">
            <xsl:value-of select="$text"/>
          </fo:basic-link>
        </fo:block>
        <fo:block text-align="center">
          <fo:basic-link color="lightgrey"
            external-destination="{$url}">
            <xsl:value-of select="$url"/>
          </fo:basic-link>
        </fo:block>
      </xsl:if>
    </fo:block-container>
  </xsl:template>

</xsl:stylesheet>
