Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / to / lists / lists.xsl @ 187

History | View | Annotate | Download (9.7 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
3
                xmlns:cals="http://www.oasis-open.org/specs/tm9901"
4
                xmlns:contypes="http://schemas.openxmlformats.org/package/2006/content-types"
5
                xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
6
                xmlns:dc="http://purl.org/dc/elements/1.1/"
7
                xmlns:dcmitype="http://purl.org/dc/dcmitype/"
8
                xmlns:dcterms="http://purl.org/dc/terms/"
9
                xmlns:html="http://www.w3.org/1999/xhtml"
10
                xmlns:iso="http://www.iso.org/ns/1.0"
11
                xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
12
                xmlns:mml="http://www.w3.org/1998/Math/MathML"
13
                xmlns:o="urn:schemas-microsoft-com:office:office"
14
                xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
15
                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
16
                xmlns:tbx="http://www.lisa.org/TBX-Specification.33.0.html"
17
                xmlns:tei="http://www.tei-c.org/ns/1.0"
18
                xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"
19
                xmlns:teix="http://www.tei-c.org/ns/Examples"
20
                xmlns:v="urn:schemas-microsoft-com:vml"
21
                xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
22
                xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006"
23
                xmlns:w10="urn:schemas-microsoft-com:office:word"
24
                xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
25
                xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
26
                xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
27
                
28
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
29
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
31
                version="2.0"
32
                exclude-result-prefixes="cp ve o r m v wp w10 w wne mml tbx iso      tei a xs pic fn xsi dc dcterms dcmitype     contypes teidocx teix html cals">
33

    
34

    
35
    <xsl:key name="AN"
36
	 match="w:abstractNum"
37
	 use="w:lvl/w:pStyle/@w:val"/>
38
    <xsl:key name="NUMS"
39
	     match="w:num[not(w:lvlOverride)]"
40
	     use="w:abstractNumId/@w:val"/>
41
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
42
      <desc>
43
         <p> TEI stylesheet for making Word docx files from TEI XML </p>
44
         <p>This software is dual-licensed:
45

    
46
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
47
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
48

    
49
2. http://www.opensource.org/licenses/BSD-2-Clause
50
		
51
All rights reserved.
52

    
53
Redistribution and use in source and binary forms, with or without
54
modification, are permitted provided that the following conditions are
55
met:
56

    
57
* Redistributions of source code must retain the above copyright
58
notice, this list of conditions and the following disclaimer.
59

    
60
* Redistributions in binary form must reproduce the above copyright
61
notice, this list of conditions and the following disclaimer in the
62
documentation and/or other materials provided with the distribution.
63

    
64
This software is provided by the copyright holders and contributors
65
"as is" and any express or implied warranties, including, but not
66
limited to, the implied warranties of merchantability and fitness for
67
a particular purpose are disclaimed. In no event shall the copyright
68
holder or contributors be liable for any direct, indirect, incidental,
69
special, exemplary, or consequential damages (including, but not
70
limited to, procurement of substitute goods or services; loss of use,
71
data, or profits; or business interruption) however caused and on any
72
theory of liability, whether in contract, strict liability, or tort
73
(including negligence or otherwise) arising in any way out of the use
74
of this software, even if advised of the possibility of such damage.
75
</p>
76
         <p>Author: See AUTHORS</p>
77
         <p>Id: $Id: lists.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
78
         <p>Copyright: 2008, TEI Consortium</p>
79
      </desc>
80
   </doc>
81

    
82
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
83
      <desc>
84
        Handle value lists
85
    </desc>
86
   </doc>
87
    <xsl:template match="tei:label[following-sibling::tei:*[1]/self::tei:item]">
88
        <xsl:param name="nop"/>
89

    
90
        <w:p>
91
            <w:pPr>
92
                <w:pStyle w:val="dl"/>
93
                <w:ind w:left="567" w:hanging="567"/>
94
            </w:pPr>
95
            <xsl:apply-templates>
96
                <xsl:with-param name="nop">true</xsl:with-param>
97
            </xsl:apply-templates>
98
            <w:r>
99
                <w:tab/>
100
            </w:r>
101
            <xsl:for-each select="following-sibling::tei:item[1]">
102
                <xsl:apply-templates>
103
                    <xsl:with-param name="nop">true</xsl:with-param>
104
                </xsl:apply-templates>
105
            </xsl:for-each>
106
        </w:p>
107
    </xsl:template>
108

    
109
    <xsl:template match="tei:item/tei:list">
110
        <xsl:param name="nop"/>
111
        <xsl:apply-templates>
112
            <xsl:with-param name="nop">false</xsl:with-param>
113
        </xsl:apply-templates>
114
    </xsl:template>
115

    
116
    <xsl:template match="tei:item[preceding-sibling::tei:*[1]/self::tei:label]"/>
117

    
118

    
119
    <xsl:template match="comment()"/>
120
    
121
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
122
      <desc> 
123
        Handle list items
124
    </desc>
125
   </doc>
126
    <xsl:template match="tei:item">
127
        <xsl:param name="nop"/>
128
        <xsl:variable name="listStyle">
129
            <xsl:choose>
130
                <xsl:when test="../@type='unordered' or ../@type='simple' or not(../@type)">
131
                    <xsl:call-template name="getStyleName">
132
                        <xsl:with-param name="in">
133
                            <xsl:text>List Continue</xsl:text>
134
                            <xsl:call-template name="listNumberDepth"/>
135
                        </xsl:with-param>
136
                    </xsl:call-template>
137
                </xsl:when>
138
                <xsl:when test="../@type='ordered'">
139
                    <xsl:call-template name="getStyleName">
140
                        <xsl:with-param name="in">
141
                            <xsl:text>List Number</xsl:text>
142
                            <xsl:call-template name="listNumberDepth"/>
143
                        </xsl:with-param>
144
                    </xsl:call-template>
145
                </xsl:when>
146
                <xsl:when test="../@type='termlist'"/>
147
                <xsl:otherwise>
148
                    <xsl:text>ListParagraph</xsl:text>
149
                </xsl:otherwise>
150
            </xsl:choose>
151
        </xsl:variable>
152
        <xsl:variable name="pPr">
153
            <w:pPr>
154
                <xsl:if test="string-length($listStyle) &gt; 1">
155
                    <w:pStyle w:val="{$listStyle}"/>
156
                </xsl:if>
157
                <xsl:choose>
158
                    <xsl:when test="../@type='unordered' or not(../@type)">
159
                        <w:numPr>
160
                            <w:ilvl>
161
                                <xsl:attribute name="w:val">
162
                                    <xsl:value-of select="count(ancestor::tei:list) - 1"/>
163
                                </xsl:attribute>
164
                            </w:ilvl>
165
			    <w:numId>
166
			      <xsl:attribute name="w:val">
167
				<xsl:choose>
168
				  <xsl:when
169
				      test="$isofreestanding='true'">
170
				    <xsl:text>2</xsl:text>
171
				  </xsl:when>
172
				  <xsl:otherwise>
173
				    <xsl:for-each select="document(concat($wordDirectory,'/word/numbering.xml'))">
174
				      <xsl:variable name="abstractNumId"
175
						    select="key('AN',$listStyle)/@w:abstractNumId"/>
176
				      <xsl:value-of select="key('NUMS',$abstractNumId)/@w:numId"/>
177
				    </xsl:for-each>
178
				  </xsl:otherwise>
179
				</xsl:choose>
180
			      </xsl:attribute>
181
			    </w:numId>
182
			</w:numPr>
183
                    </xsl:when>
184
                    <xsl:when test="../@type='ordered'">
185
                        <w:numPr>
186
                            <w:ilvl>
187
                                <xsl:attribute name="w:val">
188
                                    <xsl:value-of select="count(ancestor::tei:list) - 1"/>
189
                                </xsl:attribute>
190
                            </w:ilvl>
191
                            <w:numId>
192
			      <xsl:attribute name="w:val">
193
				<!-- @see template: numbering-definition ordered lists -->
194
				<xsl:variable name="CurrentList">
195
				  <xsl:value-of select="generate-id(..)"/>
196
				</xsl:variable>
197
				<xsl:for-each select="key('OL',1)">
198
				  <xsl:if test="$CurrentList=generate-id(.)">
199
				    <xsl:value-of select="position()+100"/>
200
				  </xsl:if>
201
				</xsl:for-each>
202
			      </xsl:attribute>
203
                            </w:numId>
204
                        </w:numPr>
205
                    </xsl:when>
206
                </xsl:choose>
207
            </w:pPr>
208
        </xsl:variable>
209
	<!--
210
	    <xsl:message>List item <xsl:value-of select="."/>, <xsl:value-of
211
	    select="$nop"/>, <xsl:value-of select="$listStyle"/></xsl:message>
212
	-->
213
        <xsl:call-template name="block-element">
214
            <xsl:with-param name="pPr" select="$pPr"/>
215
            <xsl:with-param name="nop" select="$nop"/>
216
        </xsl:call-template>
217
    </xsl:template>
218

    
219
    <xsl:template name="listNumberDepth">
220
        <xsl:choose>
221
            <xsl:when test="ancestor::tei:glossListEntry">
222
                <xsl:value-of select="count(ancestor::tei:list)                 + ancestor::tei:glossListEntry/@count"/>
223
            </xsl:when>
224
            <xsl:when test="parent::tei:list/ancestor::tei:list">
225
                <xsl:text> </xsl:text>
226
                <xsl:value-of select="count(ancestor::tei:list)"/>
227
            </xsl:when>
228
        </xsl:choose>
229
    </xsl:template>
230

    
231
</xsl:stylesheet>