Statistics
| Revision:

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

History | View | Annotate | Download (6.8 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
3
		xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"
4
                xmlns:cals="http://www.oasis-open.org/specs/tm9901"
5
                xmlns:contypes="http://schemas.openxmlformats.org/package/2006/content-types"
6
                xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
7
                xmlns:dc="http://purl.org/dc/elements/1.1/"
8
                xmlns:dcmitype="http://purl.org/dc/dcmitype/"
9
                xmlns:dcterms="http://purl.org/dc/terms/"
10
                xmlns:html="http://www.w3.org/1999/xhtml"
11
                xmlns:iso="http://www.iso.org/ns/1.0"
12
                xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
13
                xmlns:mml="http://www.w3.org/1998/Math/MathML"
14
                xmlns:o="urn:schemas-microsoft-com:office:office"
15
                xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
16
                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
17
                xmlns:tbx="http://www.lisa.org/TBX-Specification.33.0.html"
18
                xmlns:tei="http://www.tei-c.org/ns/1.0"
19
                xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"
20
                xmlns:teix="http://www.tei-c.org/ns/Examples"
21
                xmlns:v="urn:schemas-microsoft-com:vml"
22
                xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
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:xs="http://www.w3.org/2001/XMLSchema"
30
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
31
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
32
                version="2.0"
33
                exclude-result-prefixes="cp ve o r m v wp w10 w wne mml tbx iso   rel  tei a xs pic fn xsi dc dcterms dcmitype     contypes teidocx teix html cals">
34
    
35
    
36
    
37
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
38
      <desc>
39
         <p> TEI stylesheet for making Word docx files from TEI XML </p>
40
         <p>This software is dual-licensed:
41

    
42
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
43
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
44

    
45
2. http://www.opensource.org/licenses/BSD-2-Clause
46
		
47
All rights reserved.
48

    
49
Redistribution and use in source and binary forms, with or without
50
modification, are permitted provided that the following conditions are
51
met:
52

    
53
* Redistributions of source code must retain the above copyright
54
notice, this list of conditions and the following disclaimer.
55

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

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

    
78
    <xsl:template match="m:oMath">
79
        <xsl:apply-templates select="." mode="iden"/>
80
    </xsl:template>
81
    
82
    
83
    <xsl:template match="mml:math">
84
      <oMath xmlns="http://schemas.openxmlformats.org/officeDocument/2006/math">
85
	        <xsl:apply-templates mode="mml"/>
86
      </oMath>
87
    </xsl:template>
88
    
89
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
90
      <desc>
91
        Process Word objects
92
    </desc>
93
   </doc>
94
   <xsl:template match="w:object">
95
     <xsl:variable name="renderingProperties">
96
       <xsl:for-each select="..">
97
	 <xsl:call-template name="applyRend"/>
98
       </xsl:for-each>
99
     </xsl:variable>
100
     <w:r>
101
       <xsl:if test="$renderingProperties/*">
102
	 <w:rPr>
103
	   <xsl:copy-of select="$renderingProperties"/>
104
	 </w:rPr>
105
       </xsl:if>
106
       <xsl:copy>
107
	 <xsl:apply-templates mode="iden"/>
108
       </xsl:copy>
109
     </w:r>
110
   </xsl:template>
111

    
112
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
113
      <desc>
114
        Image data 
115
    </desc>
116
   </doc>
117
    <xsl:template match="v:imagedata" mode="iden">
118
        <xsl:variable name="current" select="@r:id"/>
119
	<xsl:copy>
120
	    <!-- override r:id -->
121
            <xsl:attribute name="r:id">
122
	      <xsl:choose>
123
		<xsl:when test="$isofreestanding='true'">
124
		  <xsl:variable name="me" select="generate-id()"/>
125
		  <xsl:for-each select="key('IMAGEDATA',1)">
126
		    <xsl:if test="generate-id()=$me">
127
		      <xsl:value-of select="concat('rId', string(1000 + position()))"/>
128
		    </xsl:if>
129
		  </xsl:for-each>
130
		</xsl:when>
131
		<xsl:otherwise>
132
		  <xsl:value-of select="document(concat($wordDirectory,'/word/_rels/document.xml.rels'))//rel:Relationship[@Target=$current]/@Id"/>
133
		</xsl:otherwise>
134
	      </xsl:choose>
135
            </xsl:attribute>
136
	</xsl:copy>
137
    </xsl:template>
138
    
139
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
140
      <desc>
141
        OLE objects
142
    </desc>
143
   </doc>
144
    <xsl:template match="o:OLEObject" mode="iden">
145
        <xsl:variable name="current" select="@r:id"/>
146
        <xsl:copy>
147
            <!-- copy all attributes -->
148
            <xsl:copy-of select="@*"/>
149
            <!-- set rId -->
150
            <xsl:attribute name="r:id">
151
	      <xsl:choose>
152
		<xsl:when test="$isofreestanding='true'">
153
		  <xsl:variable name="me" select="generate-id()"/>
154
		  <xsl:for-each select="key('OLEOBJECTS',1)">
155
		    <xsl:if test="generate-id()=$me">
156
		      <xsl:value-of select="concat('rId', string(2000 + position()))"/>
157
		    </xsl:if>
158
		  </xsl:for-each>
159
		</xsl:when>
160
		<xsl:otherwise>
161
		  <xsl:value-of select="document(concat($wordDirectory,'/word/_rels/document.xml.rels'))//rel:Relationship[@Target=$current]/@Id"/>
162
		</xsl:otherwise>
163
	      </xsl:choose>
164
            </xsl:attribute>
165
	</xsl:copy>
166
    </xsl:template>
167
    
168
</xsl:stylesheet>