Mode:

Compact lists

Showing:

Documentation
Parameters
Used by
References
Supersedes
Imported modules
Included modules
Source
Main stylesheet fo.xsl
Documentation

Description

TEI stylesheet making XSL-FO output.

This software is dual-licensed: 1. Distributed under a Creative Commons Attribution-ShareAlike 3.0 Unported License http://creativecommons.org/licenses/by-sa/3.0/ 2. http://www.opensource.org/licenses/BSD-2-Clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Author: See AUTHORS

Copyright: 2013, TEI Consortium

Imported modules
Included modules
Stylesheet version 3.0
Template horizontalRule
Namespace No namespace
Used by
Template
Import precedence 14
Source
<xsl:template name="horizontalRule">
  <leader rule-thickness="1pt"/>
</xsl:template>
Stylesheet location fo.xsl
Template makeBlock
Namespace No namespace
Used by
References
Parameters
QName Namespace
style No namespace
Import precedence 14
Source
<xsl:template name="makeBlock">
  <xsl:param name="style"/>
  <block font-size="{tei:fontSize($style)}" font-style="{tei:fontStyle($style)}" font-weight="{tei:fontWeight($style)}">
    <xsl:if test="@xml:id">
      <xsl:attribute name="id">
        <xsl:value-of select="@xml:id"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:apply-templates/>
  </block>
</xsl:template>
Stylesheet location fo.xsl
Template makeSection
Namespace No namespace
Used by
References
Template
Supersedes
Template
Parameters
QName Namespace
heading No namespace
implicitBlock No namespace
level No namespace
Import precedence 14
Source
<xsl:template name="makeSection">
  <xsl:param name="level"/>
  <xsl:param name="heading"/>
  <xsl:param name="implicitBlock">false</xsl:param>
  <xsl:variable name="temp">
    <tei:head>
      <xsl:value-of select="$heading"/>
    </tei:head>
  </xsl:variable>
  <xsl:for-each select="$temp">
    <xsl:call-template name="NumberedHeading">
      <xsl:with-param name="level" select="$level"/>
    </xsl:call-template>
  </xsl:for-each>
  <block>
    <xsl:apply-templates/>
  </block>
</xsl:template>
Stylesheet location fo.xsl
Template makeWithLabel
Namespace No namespace
Used by
Supersedes
Template
Parameters
QName Namespace
before No namespace
Import precedence 14
Source
<xsl:template name="makeWithLabel">
  <xsl:param name="before"/>
  <inline font-style="italic">
    <xsl:value-of select="$before"/>
  </inline>
  <xsl:text>: </xsl:text>
  <xsl:value-of select="normalize-space(.)"/>
</xsl:template>
Stylesheet location fo.xsl
Template makeInline
Namespace No namespace
Used by
References
Parameters
QName Namespace
after No namespace
before No namespace
style No namespace
Import precedence 14
Source
<xsl:template name="makeInline">
  <xsl:param name="before"/>
  <xsl:param name="after"/>
  <xsl:param name="style"/>
  <xsl:value-of select="$before"/>
  <inline font-style="{tei:fontStyle($style)}" font-weight="{tei:fontWeight($style)}">
    <xsl:apply-templates/>
  </inline>
  <xsl:value-of select="$after"/>
</xsl:template>
Stylesheet location fo.xsl
Template calculateTableSpecs
Documentation

Description

[fo] work out column widths
Namespace No namespace
Used by
Template
References
Parameter
Import precedence 14
Source
<xsl:template name="calculateTableSpecs">
  <xsl:variable name="tds">
    <xsl:for-each select="tei:row">
      <xsl:variable name="row">
        <xsl:for-each select="tei:cell">
          <xsl:variable name="stuff">
            <xsl:apply-templates/>
          </xsl:variable>
          <cell>
            <xsl:value-of select="string-length($stuff)"/>
          </cell>
          <xsl:if test="@cols">
            <xsl:variable name="c" select="xs:integer(@cols) - 1 "/>
            <xsl:for-each select="1 to $c">
              <cell>0</cell>
            </xsl:for-each>
          </xsl:if>
        </xsl:for-each>
      </xsl:variable>
      <xsl:for-each select="$row/fo:cell">
        <cell col="{position()}">
          <xsl:value-of select="."/>
        </cell>
      </xsl:for-each>
    </xsl:for-each>
  </xsl:variable>
  <xsl:variable name="total">
    <xsl:value-of select="sum($tds/fo:cell)"/>
  </xsl:variable>
  <!-- Intervention by MDH working on FO output for FOP 2016-12-28: the algorithm
     below works OK except in cases where it creates a column too small to hold 
     a single word. In an effort to avoid this, we'll set a minimum width of 
     10% on any column, and when the algorithm generates a column smaller than
     this, we'll simply omit the columns.
     Note: this could be improved by a better approach which creates adjusted 
     but still proportional column widths, when someone has time to do it.
    -->
  <xsl:variable name="proposedCols">
    <xsl:for-each select="$tds/fo:cell">
      <xsl:sort select="@col" data-type="number"/>
      <xsl:variable name="c" select="@col"/>
      <xsl:if test="not(preceding-sibling::fo:cell[$c=@col])">
        <xsl:variable name="len">
          <xsl:value-of select="sum(following-sibling::fo:cell[$c=@col]) + current()"/>
        </xsl:variable>
        <table-column column-number="{@col}" column-width="{$len div $total * 100}%">
          <xsl:if test="$foEngine='passivetex'">
            <xsl:attribute name="column-align" namespace="http://www.tug.org/fotex">L</xsl:attribute>
          </xsl:if>
        </table-column>
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="$proposedCols/fo:table-column/@column-width[xs:float(substring-before(., '%')) lt 10]">
      <!-- Drop the column width definitions altogether. -->
    </xsl:when>
    <xsl:otherwise>
      <xsl:sequence select="$proposedCols"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>
</xsl:text>
</xsl:template>
Stylesheet location fo.xsl
Template deriveColSpecs
Documentation

Description

[fo]
Namespace No namespace
Used by
Template
References
Import precedence 14
Source
<xsl:template name="deriveColSpecs">
  <xsl:choose>
    <xsl:when test="tei:match(@rend,'wovenodd')">
      <table-column column-number="1" column-width="25%"/>
      <table-column column-number="2" column-width="75%"/>
    </xsl:when>
    <xsl:when test="tei:match(@rend,'attDef')">
      <table-column column-number="1" column-width="20%"/>
      <table-column column-number="2" column-width="80%"/>
    </xsl:when>
    <xsl:when test="tei:match(@rend,'attList')">
      <table-column column-number="1" column-width="20%"/>
      <table-column column-number="2" column-width="80%"/>
    </xsl:when>
    <xsl:when test="not($readColSpecFile='')">
      <xsl:variable name="no">
        <xsl:call-template name="generateTableID"/>
      </xsl:variable>
      <xsl:choose>
        <xsl:when test="count($tableSpecs/Info/TableSpec[$no=@xml:id]) > 0">
          <xsl:for-each select="$tableSpecs/Info/TableSpec[$no=@xml:id]/table-column">
            <xsl:copy-of select="."/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <!--<xsl:message>Build specs for Table <xsl:value-of select="$no"/></xsl:message>-->
          <xsl:call-template name="calculateTableSpecs"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <!--<xsl:message>Build specs for Table <xsl:value-of select="$no"/></xsl:message>-->
      <xsl:call-template name="calculateTableSpecs"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location fo.xsl
Template generateTableID
Documentation

Description

[fo]
Namespace No namespace
Used by
Template
Import precedence 14
Source
<xsl:template name="generateTableID">
  <xsl:choose>
    <xsl:when test="@xml:id">
      <xsl:value-of select="@xml:id"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>Table-</xsl:text>
      <xsl:number level="any"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location fo.xsl
Variable top
Documentation

Description

Stylesheet constant for the input document.
Namespace No namespace
Select /
Used by
Supersedes
Variable
Source
<xsl:variable name="top" select="/"/>
Stylesheet location fo.xsl
Variable tableSpecs
Documentation

Description

Stylesheet constant for table specifications
Namespace No namespace
Used by
References
Parameter
Variable
Source
<xsl:variable name="tableSpecs">
  <xsl:choose>
    <xsl:when test="not($readColSpecFile='')">
      <xsl:copy-of select="document($readColSpecFile,$top)/Info"/>
    </xsl:when>
    <xsl:otherwise>
      <Info/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
Stylesheet location fo.xsl
Function tei:fontSize (style)
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
Template
Parameters
QName Namespace
style No namespace
Import precedence 14
Source
<xsl:function name="tei:fontSize" as="xs:string">
  <xsl:param name="style"/>
  <xsl:choose>
    <xsl:when test="$style='docAuthor'">14pt</xsl:when>
    <xsl:when test="$style='docTitle'">16pt</xsl:when>
    <xsl:when test="$style='titlePart'">16pt</xsl:when>
    <xsl:when test="$style='docDate'">14pt</xsl:when>
    <xsl:otherwise>12pt</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location fo.xsl
Function tei:fontStyle (style)
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
Templates
Parameters
QName Namespace
style No namespace
Import precedence 14
Source
<xsl:function name="tei:fontStyle" as="xs:string">
  <xsl:param name="style"/>
  <xsl:choose>
    <xsl:when test="$style=('bibl','docAuthor','titlem','italic','mentioned','term','foreign')">italic</xsl:when>
    <xsl:otherwise>normal</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location fo.xsl
Function tei:fontWeight (style)
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
Templates
Parameters
QName Namespace
style No namespace
Import precedence 14
Source
<xsl:function name="tei:fontWeight" as="xs:string">
  <xsl:param name="style"/>
  <xsl:choose>
    <xsl:when test="$style='docTitle'">bold</xsl:when>
    <xsl:when test="$style='titlePart'">bold</xsl:when>
    <xsl:when test="$style='bold'">bold</xsl:when>
    <xsl:otherwise>normal</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location fo.xsl
Output (default)
Namespace No namespace
Output properties
encoding indent
no
Source
<xsl:output indent="no" encoding="utf-8"/>
Stylesheet location fo.xsl
Key DIVS
Namespace No namespace
Match tei:div|tei:div1|tei:div2|tei:div3|tei:div4|tei:div5
Use '1'
Source
<xsl:key name="DIVS" match="tei:div|tei:div1|tei:div2|tei:div3|tei:div4|tei:div5" use="'1'"/>
Stylesheet location fo.xsl