Statistics
| Revision:

root / tmp / org.txm.core / res / org / txm / xml / xsl / tei / tools / docx-templates-twiddling / fixstyle.xsl @ 187

History | View | Annotate | Download (6.1 kB)

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet 
3
    version="2.0"
4
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
    xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
6
    exclude-result-prefixes="w">
7

    
8
  <xsl:output  encoding="UTF-8" standalone="yes" method="xml"/>
9

    
10
  <xsl:template match="/w:styles">
11
    <w:styles xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
12
      xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
13
      
14
      <!-- copy all existing elements -->
15
      <xsl:apply-templates/>
16
      
17
      <!-- create some new styles -->
18
      <xsl:call-template name="create-egXML"/>
19
      
20
    </w:styles>
21
  </xsl:template>
22

    
23
  <!-- identity transform -->
24
  
25
  <xsl:template match="@*|text()|comment()|processing-instruction()" >
26
    <xsl:copy-of select="."/>
27
  </xsl:template>
28
  
29
  <xsl:template match="*" >
30
    <xsl:copy>
31
      <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()" 
32
			   />
33
    </xsl:copy>
34
  </xsl:template>
35

    
36
  <xsl:template match="w:style[@w:styleId='Tabletitle']//w:numId">
37
    <w:numId w:val="5"/>
38
  </xsl:template>
39
  
40
  <xsl:template match="w:style[@w:styleId='Bibliography']//w:numId">
41
    <w:numId w:val="6"/>
42
  </xsl:template>
43

    
44
  <xsl:template match="w:style[@w:styleId='Figuretitle']//w:numId">
45
    <w:numId w:val="7"/>
46
  </xsl:template>
47
  
48
  <xsl:template match="w:spacing">
49
    <xsl:choose>
50
      <xsl:when test="ancestor::w:style[@w:styleId='Heading1']"/>
51
      <xsl:when test="ancestor::w:style[@w:styleId='Heading2']"/>
52
      <xsl:when test="ancestor::w:style[@w:styleId='Heading3']"/>
53
      <xsl:when test="ancestor::w:style[@w:styleId='Heading4']"/>
54
      <xsl:when test="ancestor::w:style[@w:styleId='Heading5']"/>
55
      <xsl:when test="ancestor::w:style[@w:styleId='Heading6']"/>
56
      <xsl:when test="ancestor::w:style[@w:styleId='Heading7']"/>
57
      <xsl:when test="ancestor::w:style[@w:styleId='Heading8']"/>
58
      <xsl:when test="ancestor::w:style[@w:styleId='Heading9']"/>
59
      
60
      <xsl:when test="ancestor::w:style[@w:styleId='ANNEX']"/>
61
      <xsl:when test="ancestor::w:style[@w:styleId='a2']"/>
62
      <xsl:when test="ancestor::w:style[@w:styleId='a3']"/>
63
      <xsl:when test="ancestor::w:style[@w:styleId='a4']"/>
64
      <xsl:when test="ancestor::w:style[@w:styleId='a5']"/>
65
      <xsl:when test="ancestor::w:style[@w:styleId='a6']"/>
66
      
67
      <xsl:otherwise>
68
        <w:spacing>
69
          <xsl:apply-templates
70
              select="*|@*|processing-instruction()|comment()|text()"
71
          />
72
        </w:spacing>
73
      </xsl:otherwise>
74
    </xsl:choose>
75
  </xsl:template>
76
  
77
  <xsl:template match="w:numPr">
78
    <xsl:choose>
79
      <xsl:when test="ancestor::w:style[@w:styleId='Heading1']">
80
        <w:numPr>
81
          <w:numId w:val="1"/>
82
        </w:numPr>
83
      </xsl:when>
84
      
85
      <xsl:when test="ancestor::w:style[@w:styleId='ANNEX']">
86
        <w:numPr>
87
          <w:numId w:val="3"/>
88
        </w:numPr>
89
      </xsl:when>
90
      <xsl:when test="ancestor::w:style[@w:styleId='a2']">
91
        <w:numPr>
92
          <w:ilvl w:val="1"/>
93
          <w:numId w:val="3"/>
94
        </w:numPr>
95
      </xsl:when>
96
      <xsl:when test="ancestor::w:style[@w:styleId='a3']">
97
        <w:numPr>
98
          <w:ilvl w:val="2"/>
99
          <w:numId w:val="3"/>
100
        </w:numPr>
101
      </xsl:when>
102
      <xsl:when test="ancestor::w:style[@w:styleId='a4']">
103
        <w:numPr>
104
          <w:ilvl w:val="3"/>
105
          <w:numId w:val="3"/>
106
        </w:numPr>
107
      </xsl:when>
108
      <xsl:when test="ancestor::w:style[@w:styleId='a5']">
109
        <w:numPr>
110
          <w:ilvl w:val="4"/>
111
          <w:numId w:val="3"/>
112
        </w:numPr>
113
      </xsl:when>
114
      <xsl:when test="ancestor::w:style[@w:styleId='a6']">
115
        <w:numPr>
116
          <w:ilvl w:val="5"/>
117
          <w:numId w:val="3"/>
118
        </w:numPr>
119
      </xsl:when>
120
      
121
      <xsl:when test="ancestor::w:style[@w:styleId='ListNumber']">
122
        <w:numPr>
123
          <w:numId w:val="8"/>
124
        </w:numPr>
125
      </xsl:when>
126

    
127
      <xsl:when test="ancestor::w:style[@w:styleId='ListNumber1']">
128
        <w:numPr>
129
          <w:ilvl w:val="1"/>
130
          <w:numId w:val="8"/>
131
        </w:numPr>
132
      </xsl:when>
133
      
134
      <xsl:when test="ancestor::w:style[@w:styleId='ListNumber2']">
135
        <w:numPr>
136
          <w:ilvl w:val="2"/>
137
          <w:numId w:val="8"/>
138
        </w:numPr>
139
      </xsl:when>
140
      
141
      <xsl:when test="ancestor::w:style[@w:styleId='ListNumber3']">
142
        <w:numPr>
143
          <w:ilvl w:val="3"/>
144
          <w:numId w:val="8"/>
145
        </w:numPr>
146
      </xsl:when>
147
      
148
      <xsl:when test="ancestor::w:style[@w:styleId='ListNumber4']">
149
        <w:numPr>
150
          <w:ilvl w:val="4"/>
151
          <w:numId w:val="8"/>
152
        </w:numPr>
153
      </xsl:when>
154
      
155
      <xsl:when test="ancestor::w:style[@w:styleId='ListNumber5']">
156
        <w:numPr>
157
          <w:ilvl w:val="5"/>
158
          <w:numId w:val="8"/>
159
        </w:numPr>
160
      </xsl:when>
161
      
162
      <xsl:when test="ancestor::w:style[@w:styleId='ListBullet']">
163
        <w:numPr>
164
          <w:numId w:val="9"/>
165
        </w:numPr>
166
      </xsl:when>
167
      
168
      
169

    
170
      <xsl:otherwise>
171
      	<w:numPr>
172
      	  <xsl:apply-templates
173
      	      select="*|@*|processing-instruction()|comment()|text()"
174
      	      />
175
      	</w:numPr>
176
      </xsl:otherwise>
177
    </xsl:choose>
178
  </xsl:template>
179
  
180
  <!-- new styles -->
181
  <xsl:template name="create-egXML">
182
    <w:style w:type="paragraph" w:customStyle="1" w:styleId="egXML">
183
      <w:name w:val="egXML"/>
184
      <w:basedOn w:val="Normal"/>
185
      <w:qFormat/>
186
      <w:pPr>
187
	<w:jc w:val="left"/>
188
      </w:pPr>
189
      <w:rPr>
190
        <w:rFonts w:ascii="Courier" w:hAnsi="Courier"/>
191
        <w:sz w:val="20"/>
192
      </w:rPr>
193
    </w:style>
194
    <w:style w:type="paragraph" w:customStyle="1" w:styleId="egXMLTable">
195
      <w:name w:val="egXMLTable"/>
196
      <w:basedOn w:val="Normal"/>
197
      <w:qFormat/>
198
      <w:pPr>
199
	<w:spacing w:before="80" w:after="0"/>
200
	<w:jc w:val="left"/>
201
      </w:pPr>
202
      <w:rPr>
203
        <w:rFonts w:ascii="Courier" w:hAnsi="Courier"/>
204
        <w:sz w:val="18"/>
205
      </w:rPr>
206
    </w:style>
207
  </xsl:template>
208
</xsl:stylesheet>