Statistics
| Revision:

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

History | View | Annotate | Download (12.5 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="TARGETS" use="1" match="tei:ref[@target]|tei:ptr[@target]"/>-->
36
    <xsl:key name="GRAPHICS" use="1" match="tei:graphic[@url]"/>
37
    <xsl:key name="OLEOBJECTS" use="1" match="o:OLEObject"/>
38
    <xsl:key name="IMAGEDATA" use="1" match="v:imagedata"/>
39

    
40
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
41
      <desc>
42
         <p> TEI stylesheet for making Word docx files from TEI XML </p>
43
         <p>This software is dual-licensed:
44

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

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

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

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

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

    
63
This software is provided by the copyright holders and contributors
64
"as is" and any express or implied warranties, including, but not
65
limited to, the implied warranties of merchantability and fitness for
66
a particular purpose are disclaimed. In no event shall the copyright
67
holder or contributors be liable for any direct, indirect, incidental,
68
special, exemplary, or consequential damages (including, but not
69
limited to, procurement of substitute goods or services; loss of use,
70
data, or profits; or business interruption) however caused and on any
71
theory of liability, whether in contract, strict liability, or tort
72
(including negligence or otherwise) arising in any way out of the use
73
of this software, even if advised of the possibility of such damage.
74
</p>
75
         <p>Author: See AUTHORS</p>
76
         <p>Id: $Id: relationships.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
77
         <p>Copyright: 2008, TEI Consortium</p>
78
      </desc>
79
   </doc>
80
    
81
    
82
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
83
      <desc>
84
        Write _rels/.rels
85
    </desc>
86
   </doc>
87
    <xsl:template name="write-docxfile-main-relationships">
88
      <xsl:if test="$debug='true'">
89
	<xsl:message>Writing out <xsl:value-of select="concat($wordDirectory,'/_rels/.rels')"/>
90
	</xsl:message>
91
      </xsl:if>
92

    
93
        <xsl:result-document href="{concat($wordDirectory,'/_rels/.rels')}" standalone="yes">
94
            <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
95
                <Relationship Id="rId1"
96
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
97
                          Target="word/document.xml"/>
98
                <Relationship Id="rId2"
99
                          Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
100
                          Target="docProps/core.xml"/>
101
                <Relationship Id="rId3"
102
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
103
                          Target="docProps/app.xml"/>
104
                <Relationship Id="rId4"
105
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties"
106
                          Target="docProps/custom.xml"/>
107
            </Relationships>
108
        </xsl:result-document>
109
    </xsl:template>
110
    
111
    
112
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
113
      <desc>
114
        Write word/_rels/document.xml.rels
115
    </desc>
116
   </doc>
117
    <xsl:template name="write-docxfile-relationships">
118
      <xsl:if test="$debug='true'">
119
	<xsl:message>Writing out <xsl:value-of select="concat($wordDirectory,'/word/_rels/document.xml.rels')"/>
120
	</xsl:message>
121
      </xsl:if>
122

    
123
        <xsl:result-document href="{concat($wordDirectory,'/word/_rels/document.xml.rels')}"
124
                           standalone="yes">
125
            <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
126
                
127
                <!-- Mandatory Relationships -->
128
                <Relationship Id="rId3"
129
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"
130
                          Target="numbering.xml"/>
131
                <Relationship Id="rId4"
132
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
133
                          Target="styles.xml"/>
134
                <Relationship Id="rId5"
135
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"
136
                          Target="settings.xml"/>
137
                <Relationship Id="rId7"
138
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"
139
                          Target="footnotes.xml"/>
140
                <Relationship Id="rId8"
141
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"
142
                          Target="endnotes.xml"/>
143
                <Relationship Id="rId9"
144
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
145
                          Target="comments.xml"/>
146
                <!-- odd stuff -->
147
                <Relationship Id="rId18"
148
                          Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"
149
                          Target="fontTable.xml"/>
150
                
151
                <!-- Any raw blips left in? -->
152
                
153
                <xsl:for-each select="key('BLIP',1)">
154
                    <xsl:choose>
155
                        <xsl:when test="@r:embed">
156
                            <Relationship Id="rId{position() + 200}"
157
                                   Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
158
                                   Target="{@r:embed}"/>
159
                        </xsl:when>
160
                        <xsl:otherwise>
161
                            <Relationship Id="rId{position() + 200}"
162
                                   Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
163
                                   Target="{@r:link}"
164
                                   TargetMode="External"/>
165
                        </xsl:otherwise>
166
                    </xsl:choose>
167
                </xsl:for-each>
168

    
169
		<!-- TEI images -->
170
                
171
                <xsl:for-each select="key('GRAPHICS',1)">
172

    
173
		  <xsl:variable name="n">
174
		    <xsl:number level="any"/>
175
		  <!--
176
		    <xsl:choose>
177
		      <xsl:when test="@n">
178
			<xsl:number level="any"/>
179
		      </xsl:when>
180
		      <xsl:otherwise>
181
			<xsl:number level="any"/>
182
		      </xsl:otherwise>
183
		    </xsl:choose>
184
		    -->
185
		  </xsl:variable>
186
                    <Relationship Id="rId{$n + 300}"
187
                             Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
188
                             Target="media/resource{$n}.{tokenize(@url,'\.')[last()]}"/>
189
                </xsl:for-each>
190
                
191
                <!-- hyperlinks -->
192

    
193
		<!-- 
194
		<xsl:for-each select="key('TARGETS',1)">
195
		  <xsl:if test="not(starts-with(@target,'#'))">
196
                    <Relationship 
197
			Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
198
			Target="{@target}" 
199
			TargetMode="External">
200
		      <xsl:attribute name="Id">
201
			<xsl:text>rId</xsl:text>
202
			<xsl:variable name="n">
203
			  <xsl:number level="any"/>
204
			</xsl:variable>
205
			<xsl:value-of select="$n + 3000"/>
206
		      </xsl:attribute>
207
		    </Relationship>
208
		  </xsl:if>
209
		</xsl:for-each>
210
		-->
211

    
212
                <!-- Formulas -->
213
                <xsl:for-each select="key('IMAGEDATA',1)">
214
                    <Relationship Id="rId{position() + 1000}"
215
                             Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
216
                             Target="{@r:id}"/>
217
                </xsl:for-each>
218
                
219
                <xsl:for-each select="key('OLEOBJECTS',1)">
220
                    <Relationship Id="rId{position() + 2000}"
221
                             Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"
222
                             Target="{@r:id}"/>
223
                </xsl:for-each>
224
                
225
                
226
                
227
                <!-- our headers and footers -->
228
                <xsl:choose>
229
                    <xsl:when test="count(key('ALLHEADERS',1))=0 and count(key('ALLFOOTERS',1))=0">
230
                        <xsl:for-each select="document($defaultHeaderFooterFile)">
231
                            <xsl:call-template name="writeRelationshipsHeadersAndFooters"/>
232
                        </xsl:for-each>
233
                    </xsl:when>
234
                    <xsl:otherwise>
235
                        <xsl:call-template name="writeRelationshipsHeadersAndFooters"/>
236
                    </xsl:otherwise>
237
                </xsl:choose>
238
            </Relationships>
239
        </xsl:result-document>
240
        
241
    </xsl:template>
242
    
243
    <xsl:template name="writeRelationshipsHeadersAndFooters">
244
        <xsl:for-each select="key('ALLFOOTERS',1)">
245
            <xsl:variable name="num">
246
                <xsl:number/>
247
            </xsl:variable>
248
            <Relationship xmlns="http://schemas.openxmlformats.org/package/2006/relationships"
249
                       Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"
250
                       Target="{concat('footer',position(),'.xml')}"
251
                       Id="{concat('rId',100+$num)}"/>
252
        </xsl:for-each>
253
        
254
        <!-- count all footers -->
255
        <xsl:for-each select="key('ALLHEADERS',1)">
256
            <xsl:variable name="num">
257
                <xsl:number/>
258
            </xsl:variable>
259
            <Relationship xmlns="http://schemas.openxmlformats.org/package/2006/relationships"
260
                       Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"
261
                       Target="{concat('header',position(),'.xml')}"
262
                       Id="{concat('rId',100+$num)}"/>
263
        </xsl:for-each>
264
    </xsl:template>
265
    
266
</xsl:stylesheet>