Showing:

Documentation
Parameters
Used by
References
Supersedes
Overriding
Included from
Source
Stylesheet figures.xsl
Documentation

Description

TEI stylesheet dealing with elements from the figures module, making LaTeX output.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Author: See AUTHORS

Id: $Id: figures.xsl 9356 2011-09-21 14:57:52Z rahtz $

Copyright: 2011, TEI Consortium

Included from
Stylesheet version 2.0
Template tei:cell
Documentation

Description

Process element cell
Namespace No namespace
Match tei:cell
Mode #default
Import precedence 4
Source
<xsl:template match="tei:cell">
  <xsl:if test="preceding-sibling::tei:cell">\tabcellsep</xsl:if>
  <xsl:choose>
    <xsl:when test="@role='label'">
      <xsl:text>\Panel{</xsl:text>
      <xsl:if test="starts-with(normalize-space(.),'[')">
        <xsl:text>{}</xsl:text>
      </xsl:if>
      <xsl:apply-templates/>
      <xsl:text>}{label}{</xsl:text>
      <xsl:choose>
        <xsl:when test="@cols">
          <xsl:value-of select="@cols"/>
        </xsl:when>
        <xsl:otherwise>1</xsl:otherwise>
      </xsl:choose>
      <xsl:text>}{</xsl:text>
      <xsl:choose>
        <xsl:when test="@align='right'">r</xsl:when>
        <xsl:when test="@align='centre'">c</xsl:when>
        <xsl:when test="@align='center'">c</xsl:when>
        <xsl:when test="@align='left'">l</xsl:when>
        <xsl:otherwise>l</xsl:otherwise>
      </xsl:choose>
      <xsl:text>}</xsl:text>
    </xsl:when>
    <xsl:when test="@cols > 1">
      <xsl:text>\multicolumn{</xsl:text>
      <xsl:value-of select="@cols"/>
      <xsl:text>}{</xsl:text>
      <xsl:if test="@role='label' or      parent::tei:row/@role='label'">
        <xsl:text>){\columncolor{label}}</xsl:text>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="@align='right'">r</xsl:when>
        <xsl:when test="@align='centre'">c</xsl:when>
        <xsl:when test="@align='center'">c</xsl:when>
        <xsl:when test="@align='left'">l</xsl:when>
        <xsl:otherwise>l</xsl:otherwise>
      </xsl:choose>
      <xsl:text>}{</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>}</xsl:text>
    </xsl:when>
    <xsl:when test="@align">
      <xsl:text>\multicolumn{1}{</xsl:text>
      <xsl:if test="@role='label' or      parent::tei:row/@role='label'">
        <xsl:text>){\columncolor{label}}</xsl:text>
      </xsl:if>
      <xsl:choose>
        <xsl:when test="@align='right'">r</xsl:when>
        <xsl:when test="@align='centre'">c</xsl:when>
        <xsl:when test="@align='center'">c</xsl:when>
        <xsl:when test="@align='left'">l</xsl:when>
        <xsl:otherwise>l</xsl:otherwise>
      </xsl:choose>
      <xsl:text>}{</xsl:text>
      <xsl:apply-templates/>
      <xsl:text>}</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:if test="starts-with(normalize-space(.),'[')">
        <xsl:text>{}</xsl:text>
      </xsl:if>
      <xsl:apply-templates/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:figDesc
Documentation

Description

Process element figDesc
Namespace No namespace
Match tei:figDesc
Mode #default
Import precedence 4
Source
<xsl:template match="tei:figDesc"/>
Stylesheet location ../latex2/figures.xsl
Template tei:figure
Documentation

Description

Process element figure
Namespace No namespace
Match tei:figure
Mode #default
References
Import precedence 4
Source
<xsl:template match="tei:figure">
  <xsl:call-template name="makeFigureStart"/>
  <xsl:apply-templates/>
  <xsl:call-template name="makeFigureEnd"/>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:graphic
Documentation

Description

Process element graphic
Namespace No namespace
Match tei:graphic
Mode #default
References
Template makePic
Import precedence 4
Source
<xsl:template match="tei:graphic">
  <xsl:call-template name="makePic"/>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:row
Documentation

Description

Process element row
Namespace No namespace
Match tei:row
Mode #default
Import precedence 4
Source
<xsl:template match="tei:row">
  <xsl:if test="@role='label'">\rowcolor{label}</xsl:if>
  <xsl:apply-templates/>
  <xsl:if test="following-sibling::tei:row">
    <xsl:text>\\</xsl:text>
    <xsl:if test="@role='label' or parent::tei:table/@rend='rules'">\hline</xsl:if>
    <xsl:text>
</xsl:text>
  </xsl:if>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:tablexref
Documentation

Description

Process element table
Namespace No namespace
Match tei:table
Mode xref
Supersedes
Template tei:tablexref
Import precedence 4
Source
<xsl:template match="tei:table" mode="xref">
  <xsl:text>the table on p. \pageref{</xsl:text>
  <xsl:value-of select="@xml:id"/>
  <xsl:text>}</xsl:text>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:table
Documentation

Description

Process element table
Namespace No namespace
Match tei:table
Mode #default
References
Template makeTable
Overriding
Template tei:table
Import precedence 4
Source
<xsl:template match="tei:table">
  <xsl:if test="@xml:id">
    <xsl:text>\label{</xsl:text>
    <xsl:value-of select="@xml:id"/>
    <xsl:text>}</xsl:text>
  </xsl:if>
  <xsl:text> \par </xsl:text>
  <xsl:choose>
    <xsl:when test="ancestor::tei:table">
      <xsl:text>\begin{tabular}</xsl:text>
      <xsl:call-template name="makeTable"/>
      <xsl:text>\end{tabular}</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>
\begin{longtable}</xsl:text>
      <xsl:call-template name="makeTable"/>
      <xsl:text>\end{longtable} \par
 </xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:table[@rend='display']xref
Documentation

Description

Process element table[@rend='display']
Namespace No namespace
Match tei:table[@rend='display']
Mode xref
Import precedence 4
Source
<xsl:template match="tei:table[@rend='display']" mode="xref">
  <xsl:text>Table </xsl:text>
  <xsl:number count="tei:table[@rend='display']" level="any"/>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tei:table[@rend='display']
Documentation

Description

Process element table[@rend='display']
Namespace No namespace
Match tei:table[@rend='display']
Mode #default
References
Template makeTable
Import precedence 4
Source
<xsl:template match="tei:table[@rend='display']">
  <xsl:text>\begin{table}</xsl:text>
  <xsl:text>\begin{center} \begin{small} \begin{tabular}</xsl:text>
  <xsl:call-template name="makeTable"/>
  <xsl:text>\end{tabular} 
      \caption{</xsl:text>
  <xsl:if test="@xml:id">\label{
    <xsl:value-of select="@xml:id"/>}</xsl:if>
  <xsl:apply-templates mode="ok" select="tei:head"/>
  <xsl:text>}
     \end{small} 
     \end{center}
     \end{table}</xsl:text>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template makeFigureStart
Documentation

Description

[latex] Make figure (start)
Namespace No namespace
Overriding
Template makeFigureStart
Import precedence 4
Source
<xsl:template name="makeFigureStart">
  <xsl:choose>
    <xsl:when test="@place='inline' and tei:head">
      <xsl:text>\begin{figure}[H]
</xsl:text>
    </xsl:when>
    <xsl:when test="@rend='display' or not(@place='inline') or tei:head or tei:p">
      <xsl:text>\begin{figure}[htbp]
</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:choose>
    <xsl:when test="@rend='center'">
      <xsl:text>\begin{center}</xsl:text>
    </xsl:when>
    <xsl:otherwise>\noindent</xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template makeFigureEnd
Documentation

Description

[latex] Make figure (end)
Namespace No namespace
Overriding
Template makeFigureEnd
Import precedence 4
Source
<xsl:template name="makeFigureEnd">
  <xsl:choose>
    <xsl:when test="tei:head or tei:p">
      <xsl:text>
\caption{</xsl:text>
      <xsl:if test="@xml:id">\label{
        <xsl:value-of select="@xml:id"/>}</xsl:if>
      <xsl:for-each select="tei:head">
        <xsl:apply-templates/>
      </xsl:for-each>
      <xsl:text>}</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:if test="@rend='center'">
    <xsl:text>\end{center}</xsl:text>
  </xsl:if>
  <xsl:choose>
    <xsl:when test="@place='inline' and tei:head">
      <xsl:text>\end{figure}
</xsl:text>
    </xsl:when>
    <xsl:when test="@rend='display' or not(@place='inline')">
      <xsl:text>\end{figure}
</xsl:text>
    </xsl:when>
  </xsl:choose>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template makePic
Documentation

Description

[latex] Make picture
Namespace No namespace
References
Template graphicsAttributes
Parameter realFigures
Overriding
Template makePic
Import precedence 4
Source
<xsl:template name="makePic">
  <xsl:if test="@xml:id">\hypertarget{
    <xsl:value-of select="@xml:id"/>}{}</xsl:if>
  <xsl:choose>
    <xsl:when test="@rend='noindent'">
      <xsl:text>\noindent</xsl:text>
    </xsl:when>
    <xsl:when test="not(preceding-sibling::*)">
      <xsl:text>\noindent</xsl:text>
    </xsl:when>
  </xsl:choose>
  <xsl:text>\includegraphics[</xsl:text>
  <xsl:call-template name="graphicsAttributes">
    <xsl:with-param name="mode">latex</xsl:with-param>
  </xsl:call-template>
  <xsl:text>]{</xsl:text>
  <xsl:choose>
    <xsl:when test="$realFigures='true'">
      <xsl:choose>
        <xsl:when test="@url">
          <xsl:value-of select="@url"/>
        </xsl:when>
        <xsl:when test="@entity">
          <xsl:value-of select="unparsed-entity-uri(@entity)"/>
        </xsl:when>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="c">
        <xsl:for-each select="ancestor-or-self::tei:figure[1]">
          <xsl:number level="any"/>
        </xsl:for-each>
      </xsl:variable>
      <xsl:text>FIG</xsl:text>
      <xsl:value-of select="$c+1000"/>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>}</xsl:text>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template makeTable
Documentation

Description

[latex]
Namespace No namespace
Used by
References
Import precedence 4
Source
<xsl:template name="makeTable">
  <xsl:variable name="r">
    <xsl:value-of select="@rend"/>
  </xsl:variable>
  <xsl:text>{</xsl:text>
  <xsl:if test="contains($r,'rules')">|</xsl:if>
  <xsl:choose>
    <xsl:when test="@preamble">
      <xsl:value-of select="@preamble"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="makePreamble-complex">
        <xsl:with-param name="r" select="$r"/>
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:text>}
</xsl:text>
  <xsl:if test="contains($r,'rules') or tei:head">
    <xsl:call-template name="tableHline"/>
  </xsl:if>
  <xsl:choose>
    <xsl:when test="tei:head and not(@rend='display')">
      <xsl:if test="not(ancestor::tei:table)">
        <xsl:text>\endfirsthead </xsl:text>
        <xsl:text>\multicolumn{</xsl:text>
        <xsl:value-of select="count(tei:row[1]/tei:cell)"/>
        <xsl:text>}{c}{</xsl:text>
        <xsl:apply-templates mode="ok" select="tei:head"/>
        <xsl:text>(cont.)}\\\hline \endhead </xsl:text>
      </xsl:if>
      <xsl:text>\caption{</xsl:text>
      <xsl:apply-templates mode="ok" select="tei:head"/>
      <xsl:text>}\\ </xsl:text>
    </xsl:when>
    <xsl:otherwise>
    </xsl:otherwise>
  </xsl:choose>
  <xsl:if test="contains($r,'rules') or tei:row[1][@role='label']">\hline</xsl:if>
  <xsl:apply-templates/>
  <xsl:if test="contains($r,'rules')">
    <xsl:text>\\ \hline </xsl:text>
  </xsl:if>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template tableHline
Namespace No namespace
Overriding
Template tableHline
Import precedence 4
Source
<xsl:template name="tableHline">
  <xsl:choose>
    <xsl:when test="ancestor::tei:table or @rend='display'">\hline</xsl:when>
    <xsl:otherwise>\hline\endfoot\hline\endlastfoot</xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template makePreamble-complex
Documentation

Description

[latex]
Namespace No namespace
Used by
Template makeTable
References
Parameter tableMaxWidth
Parameters
QName Namespace
r No namespace
Import precedence 4
Source
<xsl:template name="makePreamble-complex">
  <xsl:param name="r"/>
  <xsl:variable name="valign">
    <xsl:choose>
      <xsl:when test="contains($r,'bottomAlign')">B</xsl:when>
      <xsl:when test="contains($r,'midAlign')">M</xsl:when>
      <xsl:otherwise>P</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <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/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/cell)"/>
  </xsl:variable>
  <xsl:for-each select="$tds/cell">
    <xsl:variable name="c" select="@col"/>
    <xsl:if test="not(preceding-sibling::cell[$c=@col])">
      <xsl:variable name="len">
        <xsl:value-of select="sum(following-sibling::cell[$c=@col]) + current()"/>
      </xsl:variable>
      <xsl:value-of select="$valign"/>
      <xsl:text>{</xsl:text>
      <xsl:value-of select="($len div $total) * $tableMaxWidth"/>
      <xsl:text>\textwidth}</xsl:text>
      <xsl:if test="contains($r,'rules')">|</xsl:if>
    </xsl:if>
  </xsl:for-each>
</xsl:template>
Stylesheet location ../latex2/figures.xsl
Template makePreamble-simple
Documentation

Description

[latex]
Namespace No namespace
Parameters
QName Namespace
r No namespace
Import precedence 4
Source
<xsl:template name="makePreamble-simple">
  <xsl:param name="r"/>
  <xsl:for-each select="tei:row[1]/tei:cell">
    <xsl:text>l</xsl:text>
    <xsl:if test="contains($r,'rules')">|</xsl:if>
  </xsl:for-each>
</xsl:template>
Stylesheet location ../latex2/figures.xsl