Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / latex2 / tei.xsl @ 187

History | View | Annotate | Download (6.4 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:s="http://www.ascc.net/xml/schematron"
3
		xmlns:xs="http://www.w3.org/2001/XMLSchema"                
4
                xmlns:tei="http://www.tei-c.org/ns/1.0"
5
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6
                exclude-result-prefixes="s xs tei"
7
                version="2.0">
8
  <xsl:import href="../common2/tei.xsl"/>
9
  <xsl:import href="tei-param.xsl"/>
10
  <xsl:import href="../common2/verbatim.xsl"/>
11
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
12
      <desc>
13
         <p>
14
    TEI stylesheet for making LaTeX output.
15
      </p>
16
         <p>This software is dual-licensed:
17

    
18
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
19
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
20

    
21
2. http://www.opensource.org/licenses/BSD-2-Clause
22
		
23
All rights reserved.
24

    
25
Redistribution and use in source and binary forms, with or without
26
modification, are permitted provided that the following conditions are
27
met:
28

    
29
* Redistributions of source code must retain the above copyright
30
notice, this list of conditions and the following disclaimer.
31

    
32
* Redistributions in binary form must reproduce the above copyright
33
notice, this list of conditions and the following disclaimer in the
34
documentation and/or other materials provided with the distribution.
35

    
36
This software is provided by the copyright holders and contributors
37
"as is" and any express or implied warranties, including, but not
38
limited to, the implied warranties of merchantability and fitness for
39
a particular purpose are disclaimed. In no event shall the copyright
40
holder or contributors be liable for any direct, indirect, incidental,
41
special, exemplary, or consequential damages (including, but not
42
limited to, procurement of substitute goods or services; loss of use,
43
data, or profits; or business interruption) however caused and on any
44
theory of liability, whether in contract, strict liability, or tort
45
(including negligence or otherwise) arising in any way out of the use
46
of this software, even if advised of the possibility of such damage.
47
</p>
48
         <p>Author: See AUTHORS</p>
49
         <p>Id: $Id: tei.xsl 10197 2012-03-28 21:44:10Z rahtz $</p>
50
         <p>Copyright: 2011, TEI Consortium</p>
51
      </desc>
52
   </doc>
53
  <xsl:output method="text" encoding="utf8"/>
54
  <xsl:strip-space elements="*"/>
55
  <xsl:preserve-space elements="tei:hi tei:emph tei:foreign tei:p"/>
56
  <xsl:include href="core.xsl"/>
57
  <xsl:include href="corpus.xsl"/>
58
  <xsl:include href="drama.xsl"/>
59
  <xsl:include href="figures.xsl"/>
60
  <xsl:include href="header.xsl"/>
61
  <xsl:include href="linking.xsl"/>
62
  <xsl:include href="namesdates.xsl"/>
63
  <xsl:include href="tagdocs.xsl"/>
64
  <xsl:include href="textstructure.xsl"/>
65
  <xsl:include href="transcr.xsl"/>
66
  <xsl:include href="verse.xsl"/>
67
  <xsl:include href="textcrit.xsl"/>
68

    
69
  <xsl:param name="startNamespace">\color{red}</xsl:param>
70
  <xsl:param name="startElement">{</xsl:param>
71
  <xsl:param name="highlightStartElementName">\textcolor{red}{</xsl:param>
72
  <xsl:param name="highlightEndElementName">}</xsl:param>
73
  <xsl:param name="startElementName">\textbf{</xsl:param>
74
  <xsl:param name="startAttribute">{</xsl:param>
75
  <xsl:param name="startAttributeValue">{</xsl:param>
76
  <xsl:param name="startComment">\begin{it}</xsl:param>
77
  <xsl:param name="endElement">}</xsl:param>
78
  <xsl:param name="endElementName">}</xsl:param>
79
  <xsl:param name="endComment">\end{it}</xsl:param>
80
  <xsl:param name="endAttribute">}</xsl:param>
81
  <xsl:param name="endAttributeValue">}</xsl:param>
82
  <xsl:param name="endNamespace"/>
83
  <xsl:param name="spaceCharacter">\hspace*{6pt}</xsl:param>
84
  <xsl:variable name="docClass">
85
      <xsl:choose>
86
         <xsl:when test="/tei:TEI[@rend='letter']">
87
            <xsl:text>letter</xsl:text>
88
         </xsl:when>
89
         <xsl:when test="/tei:TEI[@rend='book']">
90
            <xsl:text>book</xsl:text>
91
         </xsl:when>
92
         <xsl:otherwise>
93
            <xsl:text>article</xsl:text>
94
         </xsl:otherwise>
95
      </xsl:choose>
96
  </xsl:variable>
97
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
98
      <desc>Process elements  processing-instruction()[name(.)='tex']</desc>
99
   </doc>
100
  <xsl:template match="processing-instruction()[name(.)='tex']">
101
      <xsl:value-of select="."/>
102
  </xsl:template>
103

    
104
  <xsl:template name="verbatim-lineBreak">
105
      <xsl:param name="id"/>
106
      <xsl:text>\mbox{}\newline 
107
</xsl:text>
108
  </xsl:template>
109

    
110
  <xsl:template name="verbatim-createElement">
111
      <xsl:param name="name"/>
112
      <xsl:param name="special"/>
113
      <xsl:text>\textbf{</xsl:text>
114
      <xsl:value-of select="$name"/>
115
      <xsl:text>}</xsl:text>
116
  </xsl:template>
117

    
118
  <xsl:template name="verbatim-newLine"/>
119

    
120
  <xsl:template name="verbatim-createAttribute">
121
      <xsl:param name="name"/>
122
      <xsl:value-of select="$name"/>
123
  </xsl:template>
124

    
125
  <xsl:template name="verbatim-Text">
126
      <xsl:param name="words"/>
127
      <xsl:choose>
128
         <xsl:when test="parent::*/@xml:lang='zh-TW'">
129
	           <xsl:text>{\textChinese </xsl:text>
130
		   <xsl:value-of select="tei:escapeCharsVerbatim($words)"/>
131
	           <xsl:text>}</xsl:text>
132
         </xsl:when>
133
         <xsl:when test="parent::*/@xml:lang='ja'">
134
	           <xsl:text>{\textJapanese </xsl:text>
135
		   <xsl:value-of select="tei:escapeCharsVerbatim($words)"/>
136
	           <xsl:text>}</xsl:text>
137
         </xsl:when>
138
         <xsl:when test="parent::*/@xml:lang='kr'">
139
	           <xsl:text>{\textKorean </xsl:text>
140
		   <xsl:value-of select="tei:escapeCharsVerbatim($words)"/>
141
	           <xsl:text>}</xsl:text>
142
         </xsl:when>
143
         <xsl:otherwise>
144
	   <xsl:value-of select="tei:escapeCharsVerbatim($words)"/>
145
         </xsl:otherwise>
146
      </xsl:choose>
147

    
148
  </xsl:template>
149

    
150

    
151
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
152
      <desc><p>We need the backslash and two curly braces to insert LaTeX
153
      commands into the output, so these characters need to replaced when they
154
      are found in running text. </p></desc>
155
  </doc>
156
  <xsl:function name="tei:escapeCharsVerbatim" as="xs:string">
157
    <xsl:param name="letters"/>
158
    <xsl:value-of select="translate($letters, '\{}','⃥❴❵')"/>
159
  </xsl:function>
160

    
161
  <xsl:function name="tei:escapeChars" as="xs:string">
162
    <xsl:param name="letters"/>
163
      <xsl:value-of
164
	  select="replace(replace(replace(replace(translate($letters,'&#10;',' '), 
165
		  '\\','\\textbackslash '),
166
		  '\{','\\{'),
167
		  '\}','\\}'),
168
		  '~','\\textasciitilde ')"/>
169
  </xsl:function>
170

    
171

    
172
</xsl:stylesheet>