Statistics
| Revision:

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

History | View | Annotate | Download (9.3 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
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
35
      <desc>
36
         <p> TEI stylesheet for making Word docx files from TEI XML </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: application.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
71
         <p>Copyright: 2008, TEI Consortium</p>
72
      </desc>
73
   </doc>
74

    
75
    <xsl:template name="write-docxfile-docprops-core">
76
        <xsl:variable name="now" select="tei:whatsTheDate()"/>
77

    
78
        <xsl:variable name="coreFile">
79
            <xsl:value-of select="$wordDirectory"/>
80
            <xsl:text>/docProps/core.xml</xsl:text>
81
        </xsl:variable>
82

    
83
        <xsl:variable name="createdDate">
84
            <xsl:choose>
85
                <xsl:when test="doc-available($coreFile)">
86
                    <xsl:for-each select="document($coreFile)">
87
                        <xsl:value-of select="cp:coreProperties/dcterms:created"/>
88
                    </xsl:for-each>
89
                </xsl:when>
90
                <xsl:otherwise>
91
                    <xsl:value-of select="$now"/>
92
                </xsl:otherwise>
93
            </xsl:choose>
94
        </xsl:variable>
95

    
96
        <xsl:variable name="revision">
97
            <xsl:choose>
98
                <xsl:when test="doc-available($coreFile)">
99
                    <xsl:for-each select="document($coreFile)">
100
                        <xsl:value-of select="cp:coreProperties/cp:revision + 1"/>
101
                    </xsl:for-each>
102
                </xsl:when>
103
                <xsl:otherwise>1</xsl:otherwise>
104
            </xsl:choose>
105
        </xsl:variable>
106

    
107
        <!-- after opening core.xml, we cannot write back to it; so save
108
            under new name -->
109
	<xsl:if test="$debug='true'">
110
	        <xsl:message>Writing out <xsl:value-of select="concat($wordDirectory,'/docProps/newcore.xml')"/>
111
         </xsl:message>
112
	     </xsl:if>
113

    
114
        <xsl:result-document href="{concat($wordDirectory,'/docProps/newcore.xml')}" standalone="yes">
115
            <cp:coreProperties>
116
                <dc:title>
117
		  <xsl:variable name="t">
118
                    <xsl:call-template name="generateTitle"/>
119
		  </xsl:variable>
120
		  <xsl:value-of select="$t"/>
121
                </dc:title>
122
                <dc:creator>
123
		  <xsl:variable name="a">
124
                    <xsl:call-template name="generateAuthor"/>
125
		  </xsl:variable>
126
		  <xsl:value-of select="$a"/>
127
                </dc:creator>
128
                <cp:lastModifiedBy>TEI stylesheets</cp:lastModifiedBy>
129
                <cp:revision>
130
                    <xsl:value-of select="$revision"/>
131
                </cp:revision>
132
                <dcterms:created xsi:type="dcterms:W3CDTF">
133
                    <xsl:value-of select="$createdDate"/>
134
                </dcterms:created>
135
                <dcterms:modified xsi:type="dcterms:W3CDTF">
136
                    <xsl:value-of select="$now"/>
137
                </dcterms:modified>
138
            </cp:coreProperties>
139
        </xsl:result-document>
140
    </xsl:template>
141

    
142

    
143
    <xsl:template name="write-docxfile-docprops-app">
144
	     <xsl:if test="$debug='true'">
145
	        <xsl:message>Writing out <xsl:value-of select="concat($wordDirectory,'/docProps/app.xml')"/>
146
         </xsl:message>
147
	     </xsl:if>
148

    
149
        <xsl:result-document href="{concat($wordDirectory,'/docProps/app.xml')}" standalone="yes">
150
            <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
151
                     xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
152
                <Template>STD_3_0_0.dotx</Template>
153
                <Application>TEIISO tei-docx.xsl</Application>
154
                <DocSecurity>0</DocSecurity>
155
                <SharedDoc>true</SharedDoc>
156
                <AppVersion>1.0</AppVersion>
157
            </Properties>
158
        </xsl:result-document>
159
    </xsl:template>
160

    
161
    <!-- after opening custom.xml, we cannot write back to it; so save
162
	 under new name -->
163
    <xsl:template name="write-docxfile-docprops-custom">
164
	     <xsl:if test="$debug='true'">
165
	        <xsl:message>Writing out <xsl:value-of select="concat($wordDirectory,'/docProps/newcustom.xml')"/>    </xsl:message>
166
	     </xsl:if>
167
        <xsl:result-document href="{concat($wordDirectory,'/docProps/newcustom.xml')}" standalone="yes">
168
            <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
169
                     xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
170
                <property pid="1001" name="TEI_toDOCX">
171
                    <xsl:attribute name="fmtid">
172
                        <xsl:text>{D5CDD505-2E9C-101B-9397-08002B2CF9AE}</xsl:text>
173
                    </xsl:attribute>
174
                    <vt:lpwstr>2.15.0</vt:lpwstr>
175
                </property>
176
                <xsl:for-each select="ancestor-or-self::tei:TEI/tei:teiHeader/tei:encodingDesc/tei:appInfo/tei:application">
177
                    <xsl:if test="not(@ident='TEI_toDOCX')">
178
                        <property name="{@ident}">
179
                            <xsl:attribute name="pid">
180
                                <xsl:value-of select="position()+1001"/>
181
                            </xsl:attribute>
182
                            <xsl:attribute name="fmtid">
183
                                <xsl:text>{D5CDD505-2E9C-101B-9397-08002B2CF9AE}</xsl:text>
184
                            </xsl:attribute>
185
                            <vt:lpwstr>
186
                                <xsl:value-of select="@version"/>
187
                            </vt:lpwstr>
188
                        </property>
189
                    </xsl:if>
190
                </xsl:for-each>
191
            </Properties>
192
        </xsl:result-document>
193
    </xsl:template>
194

    
195
</xsl:stylesheet>