Mode:

Compact lists

Showing:

Documentation
Parameters
Used by
References
Included from
Source
Stylesheet pass2.xsl
Documentation

Description

TEI stylesheet for converting Word docx files to TEI

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: pass2.xsl 9646 2011-11-05 23:39:08Z rahtz $

Copyright: 2008, TEI Consortium

Included from
Stylesheet version 2.0
Template @*|comment()|processing-instruction()pass2
Namespace No namespace
Match @*|comment()|processing-instruction()
Mode pass2
Import precedence 6
Source
<xsl:template match="@*|comment()|processing-instruction()" mode="pass2">
  <xsl:copy-of select="."/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template *pass2
Namespace No namespace
Match *
Mode pass2
Import precedence 6
Source
<xsl:template match="*" mode="pass2">
  <xsl:copy>
    <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass2"/>
  </xsl:copy>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template text()pass2
Namespace No namespace
Match text()
Mode pass2
Import precedence 6
Source
<xsl:template match="text()" mode="pass2">
  <xsl:value-of select="."/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:p[not(*) and string-length(.)=0]pass2
Documentation

Description

Zap empty p and item

Namespace No namespace
Match tei:p[not(*) and string-length(.)=0]
Mode pass2
Import precedence 6
Priority 99
Source
<xsl:template match="tei:p[not(*) and string-length(.)=0]" mode="pass2" priority="99"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:list/tei:listpass2
Documentation

Description

Inner lists in lists must be moved to inside items

Namespace No namespace
Match tei:list/tei:list
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:list/tei:list" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:itempass2
Namespace No namespace
Match tei:item
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:item" mode="pass2">
  <xsl:choose>
    <xsl:when test="not(*) and string-length(.)=0"/>
    <xsl:otherwise>
      <item>
        <xsl:copy-of select="@*"/>
        <xsl:variable name="me" select="generate-id()"/>
        <xsl:apply-templates mode="pass2"/>
        <!-- find following sibling lists and notes -->
        <xsl:for-each select="following-sibling::tei:list[preceding-sibling::tei:item[1][generate-id()=$me]]">
          <list>
            <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass2"/>
          </list>
        </xsl:for-each>
      </item>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:head/text()pass2
Documentation

Description

Zap emdashes at start of head

Namespace No namespace
Match tei:head/text()
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:head/text()" mode="pass2">
  <xsl:choose>
    <xsl:when test="starts-with(.,'— ')">
      <xsl:value-of select="substring(.,3)"/>
    </xsl:when>
    <xsl:when test="starts-with(.,' — ')">
      <xsl:value-of select="substring(.,4)"/>
    </xsl:when>
    <xsl:when test="starts-with(.,' — ')">
      <xsl:value-of select="substring(.,4)"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:seg[not(@*)]pass2
Documentation

Description

A <seg> which does nothing is not worth having

Namespace No namespace
Match tei:seg[not(@*)]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:seg[not(@*)]" mode="pass2">
  <xsl:choose>
    <xsl:when test="parent::tei:formula and normalize-space(.)=''"/>
    <xsl:when test=".=' ' and following-sibling::node()[1][self::tei:hi]/@rend=        preceding-sibling::node()[1][self::tei:hi]/@rend"/>
    <xsl:when test="parent::*/text()">
      <xsl:value-of select="."/>
    </xsl:when>
    <xsl:when test="parent::tei:hi[count(*)=1]">
      <xsl:value-of select="."/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:copy-of select="."/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:textpass2
Documentation

Description

Look at the sections we have generated, and put them in <front> or <body> as appropriate

Namespace No namespace
Match tei:text
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:text" mode="pass2">
  <text>
    <xsl:for-each select="tei:fw">
      <xsl:copy-of select="."/>
    </xsl:for-each>
    <body>
      <xsl:for-each select="tei:body/tei:*">
        <xsl:apply-templates select="." mode="pass2"/>
      </xsl:for-each>
    </body>
  </text>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:listBibl/tei:ppass2
Documentation

Description

A <p> inside a listBibl is moved out

Namespace No namespace
Match tei:listBibl/tei:p
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:listBibl/tei:p" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:listBiblpass2
Namespace No namespace
Match tei:listBibl
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:listBibl" mode="pass2">
  <xsl:for-each select="tei:p">
    <p>
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass2"/>
    </p>
  </xsl:for-each>
  <listBibl>
    <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass2"/>
  </listBibl>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:GLOSSITEMpass2
Documentation

Description

Gloss list from tei to docx


Description

 <GLOSSITEM>
	 <hi rend="bold">100</hi>
	 <lb/>first item </GLOSSITEM>
    
Namespace No namespace
Match tei:GLOSSITEM
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:GLOSSITEM" mode="pass2">
  <label>
    <xsl:for-each select="tei:hi">
      <xsl:apply-templates/>
    </xsl:for-each>
  </label>
  <item>
    <xsl:apply-templates mode="inglossitem"/>
  </item>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template *inglossitem
Namespace No namespace
Match *
Mode inglossitem
Import precedence 6
Source
<xsl:template match="*" mode="inglossitem">
  <xsl:apply-templates select="." mode="pass2"/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:lbinglossitem
Namespace No namespace
Match tei:lb
Mode inglossitem
Import precedence 6
Source
<xsl:template match="tei:lb" mode="inglossitem"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[@rend='bold']inglossitem
Namespace No namespace
Match tei:hi[@rend='bold']
Mode inglossitem
Import precedence 6
Source
<xsl:template match="tei:hi[@rend='bold']" mode="inglossitem"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:list[@type='gloss']/tei:label[.='where']pass2
Documentation

Description

Top of a weird gloss list

Namespace No namespace
Match tei:list[@type='gloss']/tei:label[.='where']
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:list[@type='gloss']/tei:label[.='where']" mode="pass2">
  <head>
    <xsl:apply-templates/>
  </head>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:bibl/tei:g[@ref='x:tab']pass2
Documentation

Description

A tab in a <bibl>? no.

Namespace No namespace
Match tei:bibl/tei:g[@ref='x:tab']
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:bibl/tei:g[@ref='x:tab']" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:gloss//tei:g[@ref='x:tab']pass2
Documentation

Description

A tab in a <gloss>? no.

Namespace No namespace
Match tei:gloss//tei:g[@ref='x:tab']
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:gloss//tei:g[@ref='x:tab']" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:head/tei:g[@ref='x:tab']pass2
Documentation

Description

A tab in a <head>? no.


Description

 removed 2010-03-15, seems to screw up formulae
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
      <desc>
         <p>     A tab in a &lt;formula&gt;? no. </p>
      </desc>
    </doc>

    <xsl:template match="tei:formula//tei:g[@ref='x:tab']" mode="pass2"/>
    
Namespace No namespace
Match tei:head/tei:g[@ref='x:tab']
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:head/tei:g[@ref='x:tab']" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:item[not(*) and not(text())]pass2
Documentation

Description

An empty item

Namespace No namespace
Match tei:item[not(*) and not(text())]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:item[not(*) and not(text())]" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:bibl[not(*) and not(text())]pass2
Documentation

Description

Zap empty <bibl>
Namespace No namespace
Match tei:bibl[not(*) and not(text())]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:bibl[not(*) and not(text())]" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:availability[not(*) and not(text())]pass2
Documentation

Description

Zap empty <availability>
Namespace No namespace
Match tei:availability[not(*) and not(text())]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:availability[not(*) and not(text())]" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:note[not(*) and not(text())]pass2
Documentation

Description

Zap empty <note>
Namespace No namespace
Match tei:note[not(*) and not(text())]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:note[not(*) and not(text())]" mode="pass2">
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:list[@type='gloss']/tei:item/tei:g[@ref='x:tab']pass2
Namespace No namespace
Match tei:list[@type='gloss']/tei:item/tei:g[@ref='x:tab']
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:list[@type='gloss']/tei:item/tei:g[@ref='x:tab']" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[@rend='footnote_reference' and count(*)=1 and tei:note]pass2
Namespace No namespace
Match tei:hi[@rend='footnote_reference' and count(*)=1 and tei:note]
Mode pass2
Import precedence 6
Priority 99
Source
<xsl:template match="tei:hi[@rend='footnote_reference' and     count(*)=1 and tei:note]" mode="pass2" priority="99">
  <xsl:apply-templates mode="pass2"/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[not(@rend) and not(*) and string-length(.)=0]pass2
Namespace No namespace
Match tei:hi[not(@rend) and not(*) and string-length(.)=0]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:hi[not(@rend) and not(*) and string-length(.)=0]" mode="pass2">
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[@rend='Endnote_anchor']pass2
Namespace No namespace
Match tei:hi[@rend='Endnote_anchor']
Mode pass2
Import precedence 6
Priority 99
Source
<xsl:template match="tei:hi[@rend='Endnote_anchor']" mode="pass2" priority="99">
  <xsl:apply-templates mode="pass2"/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[@rend='EndnoteReference']pass2
Namespace No namespace
Match tei:hi[@rend='EndnoteReference']
Mode pass2
Import precedence 6
Priority 99
Source
<xsl:template match="tei:hi[@rend='EndnoteReference']" mode="pass2" priority="99">
  <xsl:apply-templates mode="pass2"/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[@rend='EndnoteCharacters']pass2
Namespace No namespace
Match tei:hi[@rend='EndnoteCharacters']
Mode pass2
Import precedence 6
Priority 99
Source
<xsl:template match="tei:hi[@rend='EndnoteCharacters']" mode="pass2" priority="99">
  <xsl:apply-templates mode="pass2"/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:hi[@rend]pass2
Documentation

Description

Clean up hi by merging adjacent <hi>s
Namespace No namespace
Match tei:hi[@rend]
Mode pass2
References
Template
Import precedence 6
Source
<xsl:template match="tei:hi[@rend]" mode="pass2">
  <xsl:variable name="r" select="@rend"/>
  <xsl:choose>
    <xsl:when test="count(parent::tei:speaker/*)=1 and not         (parent::tei:speaker/text())">
      <xsl:apply-templates/>
    </xsl:when>
    <xsl:when test="parent::tei:head and .=' '"/>
    <xsl:when test="not(*) and string-length(.)=0"/>
    <xsl:when test="parent::tei:item/parent::tei:list[@type='gloss']         and tei:g[@ref='x:tab']"/>
    <xsl:when test="preceding-sibling::node()[1][self::tei:hi[@rend=$r]]">
    </xsl:when>
    <xsl:when test="preceding-sibling::node()[1][self::tei:seg and .=' ']   and   preceding-sibling::node()[2][self::tei:hi[@rend=$r]]">
    </xsl:when>
    <xsl:when test="@rend='bold' and .=' '">
      <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:when test="@rend='italic' and .=' '">
      <xsl:text> </xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="ename">
        <xsl:choose>
          <xsl:when test="@rend='italic' and        ancestor::tei:bibl">title</xsl:when>
          <xsl:otherwise>hi</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:element name="{$ename}">
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates mode="pass2"/>
        <xsl:call-template name="nextHi">
          <xsl:with-param name="r" select="$r"/>
        </xsl:call-template>
      </xsl:element>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template nextHi
Namespace No namespace
Used by
References
Template
Parameters
QName Namespace
r No namespace
Import precedence 6
Source
<xsl:template name="nextHi">
  <xsl:param name="r"/>
  <xsl:for-each select="following-sibling::node()[1]">
    <xsl:choose>
      <xsl:when test="self::tei:hi[@rend=$r]">
        <xsl:apply-templates mode="pass2"/>
        <xsl:call-template name="nextHi">
          <xsl:with-param name="r" select="$r"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="self::tei:seg and .=' ' and       following-sibling::node()[1][self::tei:hi[@rend=$r]]">
        <xsl:apply-templates mode="pass2"/>
        <xsl:call-template name="nextHi">
          <xsl:with-param name="r" select="$r"/>
        </xsl:call-template>
      </xsl:when>
    </xsl:choose>
  </xsl:for-each>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:div[tei:head/tei:ANCHOR]pass2
Namespace No namespace
Match tei:div[tei:head/tei:ANCHOR]
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:div[tei:head/tei:ANCHOR]" mode="pass2">
  <xsl:copy>
    <xsl:attribute name="xml:id" select="tei:head/tei:ANCHOR[1]/@xml:id"/>
    <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass2"/>
  </xsl:copy>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:ANCHORpass2
Namespace No namespace
Match tei:ANCHOR
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:ANCHOR" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template w:bookmarkStartpass2
Namespace No namespace
Match w:bookmarkStart
Mode pass2
Import precedence 6
Source
<xsl:template match="w:bookmarkStart" mode="pass2">
  <anchor>
    <xsl:attribute name="xml:id">
      <xsl:value-of select="substring(@w:name,2)"/>
    </xsl:attribute>
  </anchor>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:cell/tei:ppass2
Documentation

Description

Paragraphs in cells not allowed
Namespace No namespace
Match tei:cell/tei:p
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:cell/tei:p" mode="pass2">
  <xsl:if test="preceding-sibling::tei:p">
    <lb/>
  </xsl:if>
  <xsl:apply-templates mode="pass2"/>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:speechpass2
Namespace No namespace
Match tei:speech
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:speech" mode="pass2"/>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:speechkeep
Namespace No namespace
Match tei:speech
Mode keep
Import precedence 6
Source
<xsl:template match="tei:speech" mode="keep">
  <p>
    <xsl:apply-templates mode="pass2"/>
  </p>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl
Template tei:speakerpass2
Namespace No namespace
Match tei:speaker
Mode pass2
Import precedence 6
Source
<xsl:template match="tei:speaker" mode="pass2">
  <sp>
    <speaker>
      <xsl:choose>
        <xsl:when test="count(*)=1 and not(text()) and tei:hi[@rend]">
          <xsl:attribute name="rend" select="tei:hi/@rend"/>
          <xsl:for-each select="tei:hi">
            <xsl:apply-templates mode="pass2"/>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates mode="pass2"/>
        </xsl:otherwise>
      </xsl:choose>
    </speaker>
    <xsl:apply-templates select="following-sibling::tei:speech[1]" mode="keep"/>
  </sp>
</xsl:template>
Stylesheet location ../../../docx/from/pass2/pass2.xsl