Statistics
| Revision:

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

History | View | Annotate | Download (5 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns="http://www.tei-c.org/ns/1.0"
3
                xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006"
4
                xmlns:o="urn:schemas-microsoft-com:office:office"
5
                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
6
		xmlns:tei="http://www.tei-c.org/ns/1.0"
7
                xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
8
                xmlns:v="urn:schemas-microsoft-com:vml"
9
                xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
10
                xmlns:w10="urn:schemas-microsoft-com:office:word"
11
                xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
12
                xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
13
                xmlns:mml="http://www.w3.org/1998/Math/MathML"
14
                xmlns:tbx="http://www.lisa.org/TBX-Specification.33.0.html"
15
                
16
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17
                version="2.0"
18
                exclude-result-prefixes="ve o r m v wp w10 w wne mml
19
					 tei tbx">
20

    
21
  <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
22
      <desc>
23
         <p> TEI Utility stylesheet for making Word docx files from TEI XML (see tei-docx.xsl)</p>
24
         <p>This software is dual-licensed:
25

    
26
1. Distributed under a Creative Commons Attribution-ShareAlike 3.0
27
Unported License http://creativecommons.org/licenses/by-sa/3.0/ 
28

    
29
2. http://www.opensource.org/licenses/BSD-2-Clause
30
		
31
All rights reserved.
32

    
33
Redistribution and use in source and binary forms, with or without
34
modification, are permitted provided that the following conditions are
35
met:
36

    
37
* Redistributions of source code must retain the above copyright
38
notice, this list of conditions and the following disclaimer.
39

    
40
* Redistributions in binary form must reproduce the above copyright
41
notice, this list of conditions and the following disclaimer in the
42
documentation and/or other materials provided with the distribution.
43

    
44
This software is provided by the copyright holders and contributors
45
"as is" and any express or implied warranties, including, but not
46
limited to, the implied warranties of merchantability and fitness for
47
a particular purpose are disclaimed. In no event shall the copyright
48
holder or contributors be liable for any direct, indirect, incidental,
49
special, exemplary, or consequential damages (including, but not
50
limited to, procurement of substitute goods or services; loss of use,
51
data, or profits; or business interruption) however caused and on any
52
theory of liability, whether in contract, strict liability, or tort
53
(including negligence or otherwise) arising in any way out of the use
54
of this software, even if advised of the possibility of such damage.
55
</p>
56
         <p>Author: See AUTHORS</p>
57
         <p>Id: $Id: pass0.xsl 10152 2012-03-12 22:58:02Z rahtz $</p>
58
         <p>Copyright: 2008, TEI Consortium</p>
59
      </desc>
60
   </doc>
61

    
62
  <xsl:key name="STYLES" match="w:style" use="@w:styleId"/>
63
  <xsl:param name="word-directory">..</xsl:param>
64
  <xsl:param name="debug">false</xsl:param>  
65
  
66
  <xsl:template match="@*|text()|comment()|processing-instruction()" mode="pass0">
67
      <xsl:copy-of select="."/>
68
  </xsl:template>
69
  
70
  <xsl:template match="w:body" mode="pass0">
71
    <xsl:copy>
72
      <xsl:choose>
73
	<xsl:when test="w:p[tei:is-firstlevel-heading(.)]"/>
74
	<xsl:otherwise>
75
	  <w:p>
76
	    <w:pPr>
77
	      <w:pStyle w:val="Heading 1"/>
78
	    </w:pPr>
79
	    <w:r>
80
	      <w:rPr>
81
		<w:sz w:val="36"/>
82
	      </w:rPr>
83
	      <w:t/>
84
	    </w:r>
85
	  </w:p>
86
	</xsl:otherwise>
87
      </xsl:choose>
88
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass0"/>
89
    </xsl:copy>
90
  </xsl:template>
91

    
92
  
93
  <xsl:template match="*" mode="pass0">
94
      <xsl:copy>
95
         <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" mode="pass0"/>
96
      </xsl:copy>
97
  </xsl:template>
98

    
99
  <xsl:template match="w:pStyle/@w:val|w:rStyle/@w:val" mode="pass0">
100
      <xsl:variable name="old" select="."/>
101
      <xsl:variable name="new">
102
	<xsl:for-each select="$styledoc">
103
	  <xsl:value-of select="key('STYLES',$old)/w:name/@w:val"/>
104
	</xsl:for-each>
105
      </xsl:variable>
106
      <xsl:attribute name="w:val">
107
         <xsl:choose>
108
	   <xsl:when test="$new=''">
109
	     <xsl:value-of select="$old"/>
110
	     <xsl:if test="$debug='true'">
111
	       <xsl:message>! style <xsl:value-of select="$old"/> ... NOT FOUND    </xsl:message>
112
	     </xsl:if>
113
	   </xsl:when>
114
	   <xsl:when test="not($new=$old)">
115
	     <xsl:if test="$debug='true'">
116
	       <xsl:message>! style <xsl:value-of select="$old"/> ... CHANGED ...  <xsl:value-of select="$new"/>
117
	       </xsl:message>
118
	     </xsl:if>
119
	     <xsl:value-of select="$new"/>
120
	   </xsl:when>
121
	   <xsl:otherwise>
122
	     <xsl:value-of select="$old"/>
123
	   </xsl:otherwise>
124
         </xsl:choose>
125
      </xsl:attribute>
126
  </xsl:template>
127
  
128

    
129
  <xsl:template
130
      match="w:r[w:instrText][normalize-space(w:instrText)='']" mode="pass0"/>
131

    
132
</xsl:stylesheet>