Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / docx / from / maths / maths.xsl @ 187

History | View | Annotate | Download (7.7 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
                xmlns:prop="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
5
                xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
6
                xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
7
                xmlns:dc="http://purl.org/dc/elements/1.1/"
8
                xmlns:dcterms="http://purl.org/dc/terms/"
9
                xmlns:dcmitype="http://purl.org/dc/dcmitype/"
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:mo="http://schemas.microsoft.com/office/mac/office/2008/main"
14
                xmlns:mv="urn:schemas-microsoft-com:mac:vml"
15
                xmlns:o="urn:schemas-microsoft-com:office:office"
16
                xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
17
                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
18
                xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"
19
                xmlns:tbx="http://www.lisa.org/TBX-Specification.33.0.html"
20
                xmlns:tei="http://www.tei-c.org/ns/1.0"
21
                xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"
22
                xmlns:v="urn:schemas-microsoft-com:vml"
23
                xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006"
24
                xmlns:w10="urn:schemas-microsoft-com:office:word"
25
                xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
26
                xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
27
                xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
28
                
29
                xmlns="http://www.tei-c.org/ns/1.0"
30
                version="2.0"
31
                exclude-result-prefixes="a cp dc dcterms dcmitype prop     iso m mml mo mv o pic r rel     tbx tei teidocx v xs ve w10 w wne wp">
32
    
33
    
34
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
35
      <desc>
36
         <p> TEI stylesheet for converting Word docx files to TEI </p>
37
         <p>This software is dual-licensed:
38

    
39
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
40
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
41

    
42
2. http://www.opensource.org/licenses/BSD-2-Clause
43
		
44
All rights reserved.
45

    
46
Redistribution and use in source and binary forms, with or without
47
modification, are permitted provided that the following conditions are
48
met:
49

    
50
* Redistributions of source code must retain the above copyright
51
notice, this list of conditions and the following disclaimer.
52

    
53
* Redistributions in binary form must reproduce the above copyright
54
notice, this list of conditions and the following disclaimer in the
55
documentation and/or other materials provided with the distribution.
56

    
57
This software is provided by the copyright holders and contributors
58
"as is" and any express or implied warranties, including, but not
59
limited to, the implied warranties of merchantability and fitness for
60
a particular purpose are disclaimed. In no event shall the copyright
61
holder or contributors be liable for any direct, indirect, incidental,
62
special, exemplary, or consequential damages (including, but not
63
limited to, procurement of substitute goods or services; loss of use,
64
data, or profits; or business interruption) however caused and on any
65
theory of liability, whether in contract, strict liability, or tort
66
(including negligence or otherwise) arising in any way out of the use
67
of this software, even if advised of the possibility of such damage.
68
</p>
69
         <p>Author: See AUTHORS</p>
70
         <p>Id: $Id: maths.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
71
         <p>Copyright: 2008, TEI Consortium</p>
72
      </desc>
73
   </doc>
74
    
75
    
76
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
77
      <desc>Handles a single paragraph that contains a math object</desc>
78
   </doc>
79
    <xsl:template match="w:p[w:pPr/w:pStyle/@w:val='Formula']" mode="paragraph">
80
        <xsl:call-template name="paragraph-formula"/>
81
    </xsl:template>
82
    
83
    
84
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
85
      <desc>
86
        
87
            //TODO: figure out why there is a priority=-1
88
        
89
    </desc>
90
   </doc>
91
    <xsl:template match="w:p[m:oMathPara]" mode="paragraph" priority="-1">
92
        <p>
93
            <formula>
94
                <xsl:apply-templates select="m:oMathPara/m:oMath"/>
95
            </formula>
96
        </p>
97
    </xsl:template>
98
    
99
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
100
      <desc>
101
        
102
            //TODO: figure out why there is a priority=-1
103
        
104
    </desc>
105
   </doc>
106
    <xsl:template match="w:p[m:oMath]" mode="paragraph" priority="-1">
107
        <p>
108
            <formula>
109
                <xsl:apply-templates select="m:oMath"/>
110
            </formula>
111
        </p>
112
    </xsl:template>
113
    
114
    
115
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
116
      <desc>named template for w:p[w:pPr/w:pStyle/@w:val='Formula'</desc>
117
   </doc>
118
    <xsl:template name="paragraph-formula">
119
        <p>
120
            <formula>
121
                <xsl:if test="w:r/w:rPr/w:rStyle/@w:val='FormulaReference'">
122
                    <xsl:attribute name="n">
123
                        <xsl:value-of select="w:r[w:rPr/w:rStyle/@w:val='FormulaReference']/w:t"/>
124
                    </xsl:attribute>
125
                </xsl:if>
126
                <xsl:apply-templates/>
127
            </formula>
128
        </p>
129
    </xsl:template>
130

    
131
    
132
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
133
      <desc>
134
        Depending on the math mode, omml is either converted to mathML or an identity transformation is started
135
    </desc>
136
   </doc>
137
    <xsl:template match="m:oMath">
138
        <xsl:choose>
139
            <xsl:when test="$mathMethod='omml'">
140
                <xsl:apply-templates select="." mode="iden"/>
141
            </xsl:when>
142
            <xsl:otherwise>
143
                <mml:math>
144
                    <xsl:apply-templates/>
145
                </mml:math>
146
            </xsl:otherwise>
147
        </xsl:choose>
148
    </xsl:template>
149

    
150
    
151
    
152
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
153
      <desc>
154
         <p>Handles a w:object by copying it</p>
155
      </desc>
156
   </doc>
157
    <xsl:template match="w:object">
158
      <xsl:copy>
159
	<xsl:apply-templates mode="iden"/>
160
      </xsl:copy>
161
    </xsl:template>
162
    
163
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
164
      <desc>
165
        Guides the identity transformation of imagedata in math
166
    </desc>
167
   </doc>
168
    <xsl:template match="v:imagedata" mode="iden">
169
            <xsl:variable name="rid" select="@r:id"/>
170
            <xsl:variable name="file">
171
                <xsl:value-of
172
		    select="document(concat($wordDirectory,'/word/_rels/document.xml.rels'))//rel:Relationship[@Id=$rid]/@Target"/>
173
	    </xsl:variable>
174
	    <v:imagedata r:id="{$file}"/>
175
    </xsl:template>
176
    
177
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
178
      <desc>
179
        Guides the identity transformation of ole in maths
180
    </desc>
181
   </doc>
182
    <xsl:template match="o:OLEObject" mode="iden">
183
        <o:OLEObject>
184
            <xsl:copy-of select="@*"/>
185
            <xsl:variable name="rid" select="@r:id"/>
186
            <xsl:variable name="file">
187
                <xsl:value-of
188
		    select="document(concat($wordDirectory,'/word/_rels/document.xml.rels'))//rel:Relationship[@Id=$rid]/@Target"/>
189
	    </xsl:variable>
190
            <xsl:attribute name="r:id">
191
                <xsl:value-of select="$file"/>
192
            </xsl:attribute>
193
        </o:OLEObject>
194
    </xsl:template>
195
    
196

    
197
    
198
</xsl:stylesheet>