Mode:

Compact lists

Showing:

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

Description

TEI Utility stylesheet for making TEI XML from Word docx files

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

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

Copyright: 2013, TEI Consortium

Imported from
Stylesheet version 3.0
Function tei:isFirstlevel-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
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
Source
<xsl:function name="tei:isFirstlevel-heading" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <xsl:when test="matches($p/w:pPr/w:pStyle/@w:val,'[Hh]eading[ ]?1')">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/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
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
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/from/functions.xsl
Function tei:is-front (p)
Documentation

Description

Defines whether or not a word paragraph is a front page element.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
Source
<xsl:function name="tei:is-front" 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,'[Tt]itle.*')">true</xsl:when>
    <xsl:when test="matches($s,'[Ss]ubtitle.*')">true</xsl:when>
    <xsl:when test="matches($s,'[Dd]ate.*')">true</xsl:when>
    <xsl:when test="matches($s,'[Aa]uthor.*')">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/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
Used by
References
Variable
Parameters
QName Namespace
p No namespace
Import precedence 2
Source
<xsl:function name="tei:is-list" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:variable name="style" select="$p/w:pPr/w:pStyle/@w:val"/>
  <xsl:variable name="stylePr" select="document($styleDoc)//w:style[w:name/@w:val=$style]"/>
  <xsl:choose>
    <xsl:when test="$p/w:pPr/w:pStyle/@w:val='dl'">true</xsl:when>
    <xsl:when test="$p/w:pPr/w:numPr/w:ilvl">true</xsl:when>
    <xsl:when test="contains($style,'List') and $p/w:pPr/w:numPr[not(w:ins)]">true</xsl:when>
    <xsl:when test="contains($style,'List') and $stylePr/w:pPr/w:numPr[not(w:ins)]">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/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
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
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: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/from/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
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
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[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/from/functions.xsl
Function tei:is-caption (p)
Documentation

Description

Defines whether or not a word paragraph is a caption.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
Source
<xsl:function name="tei:is-caption" as="xs:boolean">
  <xsl:param name="p"/>
  <xsl:choose>
    <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:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/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
Used by
Parameters
QName Namespace
p No namespace
Import precedence 2
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/from/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 2
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/from/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
Used by
Template
Parameters
QName Namespace
current-header No namespace
Import precedence 2
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/from/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
Used by
Template
References
Parameters
QName Namespace
style No namespace
Import precedence 2
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>bulleted</xsl:text>
    </xsl:when>
    <xsl:when test="starts-with($style,$ListContinue)">
      <xsl:text>bulleted</xsl:text>
    </xsl:when>
    <xsl:when test="starts-with($style,$ListNumber)">
      <xsl:text>numbered</xsl:text>
    </xsl:when>
    <xsl:when test="$style=$List">
      <xsl:text>numbered</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl
Function tei:docxError (message)
Documentation

Description

insert a note that a docx conversion cannot proceed
Namespace http://www.tei-c.org/ns/1.0
Type node()+
Used by
Parameters
QName Namespace
message No namespace
Import precedence 2
Source
<xsl:function name="tei:docxError" as="node()+">
  <xsl:param name="message"/>
  <hi xmlns="http://www.tei-c.org/ns/1.0" style="color:red; font-size: 14pt; font-weight:bold;" rend="ERROR"></hi>
  <note place="margin" type="conversion" resp="#docxtotei" xmlns="http://www.tei-c.org/ns/1.0">
    <hi rend="docxError">
      <xsl:value-of select="$message"/>
    </hi>
  </note>
  <xsl:message>docx conversion issue:
    <xsl:value-of select="$message"/>
  </xsl:message>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl
Function tei:processInstruction (instr)
Documentation

Description

process a Word w:instrText
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
Template
References
Variable
Parameters
QName Namespace
instr No namespace
Import precedence 2
Source
<xsl:function name="tei:processInstruction" as="xs:string">
  <xsl:param name="instr"/>
  <xsl:variable name="instr">
    <xsl:value-of select="replace($instr, '^\s+|\s+$', '')"/>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="matches($instr, 'REF _')">
      <!-- this will also catch NOTEREF _ -->
      <xsl:value-of select="concat('#', substring-before(substring-after($instr, '_'), ' '))"/>
    </xsl:when>
    <xsl:when test="matches($instr, 'HYPERLINK \\l ')">
      <xsl:variable name="target">
        <xsl:value-of select="translate(tokenize($instr, ' ')[3], $dq, '')"/>
      </xsl:variable>
      <xsl:value-of select="             if (matches($target, '^_')) then               concat('#', substring($target, 2))             else               $target"/>
    </xsl:when>
    <xsl:when test="matches($instr, 'HYPERLINK')">
      <xsl:variable name="target">
        <xsl:value-of select="translate(tokenize($instr, ' ')[2], $dq, '')"/>
      </xsl:variable>
      <xsl:value-of select="             if (matches($target, '^_')) then               concat('#', substring($target, 2))             else               $target"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="             if (matches($instr, '(^|#)_')) then               replace($instr, '(^|#)_', '#')             else               $instr"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl
Function tei:discardInstruction (instr)
Documentation

Description

Whether a w:instrText can be discarded on not. ignore all the bibliographic addins
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Used by
Template
Parameters
QName Namespace
instr No namespace
Import precedence 2
Source
<xsl:function name="tei:discardInstruction" as="xs:boolean">
  <xsl:param name="instr"/>
  <xsl:choose>
    <xsl:when test="contains($instr,'REF _')">true</xsl:when>
    <xsl:when test="matches($instr,'^[ ]?QUOTE')">true</xsl:when>
    <xsl:when test="matches($instr,'^[ ]?XE')">true</xsl:when>
    <xsl:when test="contains($instr,'SEQ')">true</xsl:when>
    <xsl:when test="contains($instr,'FORMTEXT')">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl
Function tei:biblioInstruction (instr)
Documentation

Description

Whether a w:instrText is a bibliographic addin
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Used by
Template
Parameters
QName Namespace
instr No namespace
Import precedence 2
Source
<xsl:function name="tei:biblioInstruction" as="xs:boolean">
  <xsl:param name="instr"/>
  <xsl:choose>
    <xsl:when test="matches($instr,'^[ ]?EN.REFLIST')">true</xsl:when>
    <xsl:when test="matches($instr,'^[ ]?ADDIN')">true</xsl:when>
    <xsl:when test="matches($instr,'^[ ]?ref Mendeley Edited')">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl
Function tei:onOff (e)
Documentation

Description

Returns true or false for value types that may be "on" or "off". If the parent element exists but does not have a @w:val, the function returns true.
Namespace http://www.tei-c.org/ns/1.0
Type xs:boolean
Used by
Parameters
QName Namespace
e No namespace
Import precedence 2
Source
<xsl:function name="tei:onOff" as="xs:boolean">
  <xsl:param name="e"/>
  <xsl:choose>
    <xsl:when test="exists($e)">
      <xsl:variable name="val" select="$e/@w:val"/>
      <xsl:choose>
        <xsl:when test="not(exists($val))">
          <xsl:sequence select="true()"/>
        </xsl:when>
        <xsl:when test="$val = 'true'">
          <xsl:sequence select="true()"/>
        </xsl:when>
        <xsl:when test="$val = 'on'">
          <xsl:sequence select="true()"/>
        </xsl:when>
        <xsl:when test="$val = '1'">
          <xsl:sequence select="true()"/>
        </xsl:when>
        <xsl:when test="$val = 'false'">
          <xsl:sequence select="false()"/>
        </xsl:when>
        <xsl:when test="$val = 'none'">
          <xsl:sequence select="false()"/>
        </xsl:when>
        <xsl:when test="$val = 'off'">
          <xsl:sequence select="false()"/>
        </xsl:when>
        <xsl:when test="$val = '0'">
          <xsl:sequence select="false()"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:sequence select="false()"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:sequence select="false()"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl
Function tei:justification (jc)
Documentation

Description

Translates standard justification values into CSS text-align values.
Namespace http://www.tei-c.org/ns/1.0
Type xs:string
Used by
Parameters
QName Namespace
jc No namespace
Import precedence 2
Source
<xsl:function name="tei:justification" as="xs:string">
  <xsl:param name="jc"/>
  <xsl:choose>
    <xsl:when test="$jc/@w:val='start'">left</xsl:when>
    <xsl:when test="$jc/@w:val='end'">right</xsl:when>
    <xsl:when test="$jc/@w:val='left'">left</xsl:when>
    <xsl:when test="$jc/@w:val='right'">right</xsl:when>
    <xsl:when test="$jc/@w:val='center'">center</xsl:when>
    <xsl:when test="$jc/@w:val='both'">justify</xsl:when>
    <xsl:otherwise>left</xsl:otherwise>
  </xsl:choose>
</xsl:function>
Stylesheet location ../../../docx/from/functions.xsl