Mode:

Compact lists

Showing:

Documentation
Parameters
Used by
References
Imported from
Source
Stylesheet functions.xsl
Documentation

Description

TEI Utility stylesheet for making Word docx files from TEI XML (see docx-tei.xsl)

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 All rights reserved. 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

Id: $Id: functions.xsl 11232 2012-12-18 18:06:19Z rahtz $

Copyright: 2008, TEI Consortium

Imported from
Stylesheet version 2.0
Function tei:convert-dim-pt20 (dim)
Documentation

Description

Converts a dimension into the 20th of a point.
Namespace http://www.tei-c.org/ns/1.0
Type xs:integer
Used by
Templates
References
Parameters
QName Namespace
dim No namespace
Import precedence 4
Source
<xsl:function name="tei:convert-dim-pt20" as="xs:integer">
  <xsl:param name="dim"/>
  <xsl:value-of select="tei:convert-dim-pt($dim) * 20"/>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:convert-dim-pt (dim)
Documentation

Description

Convert a dimension into point.
Namespace http://www.tei-c.org/ns/1.0
Type xs:integer
Used by
References
Parameter
Parameters
QName Namespace
dim No namespace
Import precedence 4
Source
<xsl:function name="tei:convert-dim-pt" as="xs:integer">
  <xsl:param name="dim"/>
  <xsl:choose>
    <xsl:when test="ends-with($dim,'%')">
      <xsl:value-of select="number($pageWidth * number(substring($dim,0,string-length($dim)))) cast as xs:integer"/>
    </xsl:when>
    <xsl:when test="ends-with($dim,'cm')">
      <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*28.3464567) cast as xs:integer"/>
    </xsl:when>
    <xsl:when test="ends-with($dim,'in')">
      <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*72) cast as xs:integer"/>
    </xsl:when>
    <xsl:when test="ends-with($dim,'mm')">
      <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*2.83464567) cast as xs:integer"/>
    </xsl:when>
    <xsl:when test="ends-with($dim,'pt')">
      <xsl:value-of select="number(substring($dim,0,string-length($dim)-1)) cast as xs:integer"/>
    </xsl:when>
    <xsl:when test="ends-with($dim,'px')">
      <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*0.75) cast as xs:integer"/>
    </xsl:when>
    <xsl:otherwise>-1</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:convert-dim-emu (dim)
Documentation

Description

Convert a dimension into english metric unit.
Namespace http://www.tei-c.org/ns/1.0
Type xs:integer
Used by
Parameters
QName Namespace
dim No namespace
Import precedence 4
Source
<xsl:function name="tei:convert-dim-emu" as="xs:integer">
  <xsl:param name="dim"/>
  <xsl:variable name="result">
    <xsl:choose>
      <xsl:when test="ends-with($dim,'cm')">
        <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*3600) cast as xs:integer"/>
      </xsl:when>
      <xsl:when test="ends-with($dim,'in')">
        <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*9144) cast as xs:integer"/>
      </xsl:when>
      <xsl:when test="ends-with($dim,'mm')">
        <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*360) cast as xs:integer"/>
      </xsl:when>
      <xsl:when test="ends-with($dim,'pt')">
        <xsl:value-of select="number(number(number(substring($dim,0,string-length($dim)-1)) div 72) * 9144) cast as xs:integer"/>
      </xsl:when>
      <xsl:when test="ends-with($dim,'px')">
        <xsl:value-of select="number(number(substring($dim,0,string-length($dim)-1))*95.25) cast as xs:integer"/>
      </xsl:when>
      <xsl:otherwise>-1</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:value-of select="$result"/>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:get-listtype (style)
Documentation

Description

Returns a listtype for a given stylename (return empty string to figure it out dynamically).
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
References
Parameters
QName Namespace
style No namespace
Import precedence 4
Source
<xsl:function name="tei:get-listtype" as="xs:string">
  <xsl:param name="style"/>
  <xsl:choose>
    <xsl:when test="starts-with($style,'dl')">
      <xsl:text>gloss</xsl:text>
    </xsl:when>
    <xsl:when test="starts-with($style,$ListBullet)">
      <xsl:text>unordered</xsl:text>
    </xsl:when>
    <xsl:when test="starts-with($style,$ListContinue)">
      <xsl:text>unordered</xsl:text>
    </xsl:when>
    <xsl:when test="starts-with($style,$ListNumber)">
      <xsl:text>ordered</xsl:text>
    </xsl:when>
    <xsl:when test="$style=$List">
      <xsl:text>ordered</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:get-headingstyle (element, level)
Documentation

Description

Returns the correct heading style (return empty string to figure it out dynamically).
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
Parameters
QName Namespace
element No namespace
level No namespace
Import precedence 4
Source
<xsl:function name="tei:get-headingstyle" as="xs:string">
  <xsl:param name="element"/>
  <xsl:param name="level"/>
  <xsl:text/>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-firstlevel-heading (p)
Documentation

Description

Defines whether or not a word paragraph is a first level heading.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-firstlevel-heading" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p[w:pPr/w:pStyle/@w:val='heading 1']">true</xsl:when>
    <xsl:when test="$p[w:pPr/w:pStyle/@w:val='Heading 1']">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-heading (p)
Documentation

Description

Defines whether or not a word paragraph is a heading.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-heading" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:variable name="s" select="$p/w:pPr/w:pStyle/@w:val"/>
  <xsl:choose>
    <xsl:when test="matches($s,'[Hh]eading.+')">true</xsl:when>
    <xsl:when test="matches($s,'[Cc]aption')">true</xsl:when>
    <xsl:when test="matches($s,'Figure[ ]?title')">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-list (p)
Documentation

Description

Defines whether or not a word paragraph is a list element.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-list" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p[contains(w:pPr/w:pStyle/@w:val,'List')]">true</xsl:when>
    <xsl:when test="$p[w:pPr/w:pStyle/@w:val='dl']">true</xsl:when>
    <xsl:when test="$p/w:pPr/w:numPr[not(w:ins)]">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-toc (p)
Documentation

Description

Defines whether or not a word paragraph is a table of contents.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-toc" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p[contains(w:pPr/w:pStyle/@w:val,'toc')]">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-figure (p)
Documentation

Description

Defines whether or not a word paragraph is a figure element.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-figure" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p[matches(w:pPr/w:pStyle/@w:val,'[Ff]igure')]">true</xsl:when>
    <xsl:when test="$p[matches(w:pPr/w:pStyle/@w:val,'[Cc]aption')]">true</xsl:when>
    <xsl:when test="$p[matches(w:pPr/w:pStyle/@w:val,'Figuretitle')]">true</xsl:when>
    <xsl:when test="$p[w:r/w:drawing and not(w:r/w:t)]">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-line (p)
Documentation

Description

Defines whether or not a word paragraph is a line of poetry.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-line" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p[w:pPr/w:pStyle/@w:val='tei_l']">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:is-glosslist (p)
Documentation

Description

Defines whether or not a word paragraph is gloss list.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Parameters
QName Namespace
p No namespace
Import precedence 4
Source
<xsl:function name="tei:is-glosslist" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="$p[w:pPr/w:pStyle/@w:val='dl']">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:get-nextlevel-header (current-header)
Documentation

Description

Is given a header style and returns the style for the next level header.
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Parameters
QName Namespace
current-header No namespace
Import precedence 4
Source
<xsl:function name="tei:get-nextlevel-header" as="xs:string">
  <xsl:param name="current-header"/>
  <xsl:value-of select="translate($current-header,'12345678','23456789')"/>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl
Function tei:graphicSizes (element, filename)
Documentation

Description

Work out the size of included graphics
Namespace http://www.tei-c.org/ns/1.0
Type element()
Used by
Template
References
Variable
Keys
H;
Parameters
Function
Parameters
QName Namespace
element No namespace
filename No namespace
Import precedence 4
Source
<xsl:function name="tei:graphicSizes" as="element()">
  <xsl:param name="element"/>
  <xsl:param name="filename"/>
  <xsl:for-each select="$element">
    <xsl:variable name="origheight">
      <xsl:choose>
        <xsl:when test="@teidocx:height">
          <xsl:value-of select="@teidocx:height"/>
        </xsl:when>
        <xsl:when test="doc-available(concat($wordDirectory,'/image-size-info.xml'))">
          <xsl:for-each select="document(concat($wordDirectory,'/image-size-info.xml'))">
            <xsl:value-of select="(number(key('H',$filename)/height) div 72) * 9144"/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="origwidth">
      <xsl:choose>
        <xsl:when test="@teidocx:width">
          <xsl:value-of select="@teidocx:width"/>
        </xsl:when>
        <xsl:when test="doc-available(concat($wordDirectory,'/image-size-info.xml'))">
          <xsl:for-each select="document(concat($wordDirectory,'/image-size-info.xml'))">
            <xsl:value-of select="(number(key('W',$filename)/width) div 72) * 9144"/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <!--
                
                is there a number present?
                
                not(number(substring(@width,0,string-length(@width)-1))=NAN) and 
                not(number(substring(@height,0,string-length(@height)-1))=NAN)">
                
            -->
    <xsl:variable name="Width">
      <!-- remembering that pageWidth is already divided by 100 -->
      <xsl:choose>
        <xsl:when test="contains(@width,'%')">
          <xsl:value-of select="number($pageWidth * number(substring-before(@width,'%'))) cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="@width">
          <xsl:value-of select="tei:convert-dim-emu(@width)"/>
        </xsl:when>
        <xsl:when test="@scale and $origwidth">
          <xsl:value-of select="($origwidth *  number(@scale)) cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="@height and $origheight and $origwidth">
          <xsl:variable name="h">
            <xsl:choose>
              <xsl:when test="contains(@height,'%')">
                <xsl:value-of select="number($pageHeight * (number(substring-before(@height,'%')))) cast as xs:integer"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="tei:convert-dim-emu(@height)"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:variable>
          <xsl:value-of select="number(($h * $origwidth) div $origheight)    cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="$origwidth">
          <xsl:value-of select="$origwidth"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:message terminate="yes">no way to work out image width for
            <xsl:value-of select="$filename"/>
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="Height">
      <xsl:choose>
        <xsl:when test="contains(@height,'%')">
          <xsl:value-of select="number($pageHeight * (number(substring-before(@height,'%')))) cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="@height">
          <xsl:value-of select="tei:convert-dim-emu(@height)"/>
        </xsl:when>
        <xsl:when test="@scale and $origheight">
          <xsl:value-of select="($origheight * number(@scale)) cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="@width[contains(.,'%')]">
          <xsl:value-of select="number($pageHeight * (number(substring-before(@width,'%')))) cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="@width[not(contains(.,'%'))] and $origheight and $origwidth">
          <xsl:value-of select="number(  (number($Width) *  number($origheight)) div number($origwidth)) cast as xs:integer"/>
        </xsl:when>
        <xsl:when test="$origheight">
          <xsl:value-of select="$origheight"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:message terminate="yes">no way to work out image height for
            <xsl:value-of select="$filename"/>
          </xsl:message>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <sizes Height="{$Height}" Width="{$Width}" origheight="{$origheight}" origwidth="{$origwidth}"/>
  </xsl:for-each>
</xsl:function>
Stylesheet location ../../../docx/utils/functions.xsl