Statistics
| Revision:

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

History | View | Annotate | Download (10.8 kB)

1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
                xmlns:prop="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
5
                xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
6
                xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
7
                xmlns:dc="http://purl.org/dc/elements/1.1/"
8
                xmlns:dcterms="http://purl.org/dc/terms/"
9
                xmlns:dcmitype="http://purl.org/dc/dcmitype/"
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:mo="http://schemas.microsoft.com/office/mac/office/2008/main"
14
                xmlns:mv="urn:schemas-microsoft-com:mac:vml"
15
                xmlns:o="urn:schemas-microsoft-com:office:office"
16
                xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"
17
                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
18
                xmlns:rel="http://schemas.openxmlformats.org/package/2006/relationships"
19
                xmlns:tbx="http://www.lisa.org/TBX-Specification.33.0.html"
20
                xmlns:tei="http://www.tei-c.org/ns/1.0"
21
                xmlns:teidocx="http://www.tei-c.org/ns/teidocx/1.0"
22
                xmlns:v="urn:schemas-microsoft-com:vml"
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="http://www.tei-c.org/ns/1.0"
30
                version="2.0"
31
                exclude-result-prefixes="a cp dc dcterms dcmitype prop     iso m mml mo mv o pic r rel     tbx tei teidocx v xs ve w10 w wne wp">
32
    
33
    
34
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet" type="stylesheet">
35
      <desc>
36
         <p> TEI stylesheet for converting Word docx files to TEI </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: toc.xsl 9646 2011-11-05 23:39:08Z rahtz $</p>
71
         <p>Copyright: 2008, TEI Consortium</p>
72
      </desc>
73
   </doc>
74
    
75
    
76
    <doc xmlns="http://www.oxygenxml.com/ns/doc/xsl">
77
      <desc> Process a paragraph with a TOC style, which means parsing
78
      the instrText field </desc>
79
<!--
80
        Handle TOC
81
{ TOC [Switches ] }
82

    
83
Builds a table of contents. The TOC field collects entries for a table of 
84
contents using heading levels, specified styles (style: A combination of 
85
formatting characteristics, such as font, font size, and indentation, that 
86
you name and store as a set. When you apply a style, all of the formatting 
87
instructions in that style are applied at one time.), or entries specified by 
88
TC (Table of Contents Entry) fields. Microsoft Word inserts the TOC field 
89
when you use the Index and Tables command from the Reference submenu on the 
90
Insert menu.
91

    
92
Note  If the table of contents created by the TOC field affects the 
93
pagination of the document, you may have to update the field again to reflect 
94
the correct page numbers.
95

    
96
Switches
97

    
98
\a Identifier 
99
Lists items captioned with the Caption command (Insert menu, Reference 
100
submenu) but omits caption labels and numbers. The identifier corresponds to 
101
the caption label. For example, although a caption on page 12 is "Figure 8: 
102
Mercury", the field { TOC \a figures } displays entries as 
103
"Mercury............12".
104
Use the \c switch to build a table of captions with labels and numbers.
105

    
106
\b BookmarkName 
107
Collects entries only from the portion of the document marked by the 
108
specified bookmark (bookmark: A location or selection of text in a file that 
109
you name for reference purposes. Bookmarks identify a location within your 
110
file that you can later refer or link to.). 
111
\c "SEQIdentifier" 
112
Lists figures, tables, charts, or other items that are numbered by a SEQ 
113
(Sequence) field. Word uses SEQ fields to number items captioned with the 
114
Caption command (Insert menu, Reference submenu). SEQIdentifier, which 
115
corresponds to the caption label, must match the identifier in the SEQ field. 
116
For example, { TOC \c "tables" } lists all numbered tables. 
117
\f EntryIdentifier 
118
Builds a table from TC fields. If EntryIdentifier is specified, the table is 
119
built only from TC fields with the same identifier (typically a letter). For 
120
example, { TOC \f t } builds a table of contents from TC fields such as { TC 
121
"Entry Text" \f t }. 
122
\h Hyperlinks 
123
Inserts TOC entries as hyperlinks (hyperlink: Colored and underlined text or 
124
a graphic that you click to go to a file, a location in a file, a Web page on 
125
the World Wide Web, or a Web page on an intranet. Hyperlinks can also go to 
126
newsgroups and to Gopher, Telnet, and FTP sites.). 
127
\l Levels 
128
Builds a table of contents from TC fields that assign entries to one of the 
129
specified levels. For example, { TOC \l 1-4 } builds a table of contents from 
130
TC fields that assign entries to levels 1-4. TC fields that assign entries to 
131
lower levels are skipped. 
132
\n Levels 
133
Omits page numbers from the table of contents. Page numbers are omitted from 
134
all levels unless a range of entry levels is specified. For example, { TOC \n 
135
3-4 } omits page numbers from levels 3 and 4. Delete this switch to include 
136
page numbers. 
137
\o "Headings" 
138
Builds a table of contents from paragraphs formatted with built-in heading 
139
styles (heading style: Formatting applied to a heading. Microsoft Word has 
140
nine different built-in styles: Heading 1 through Heading 9.). For example, { 
141
TOC \o "1-3" } lists only headings formatted with the styles Heading 1 
142
through Heading 3. If no heading range is specified, all heading levels used 
143
in the document are listed. Enclose the range numbers in quotation marks. 
144
\p "Separators" 
145
Specifies the characters that separate an entry and its page number. For 
146
example, the field { TOC \p "— " }, with an em dash, displays a result such 
147
as "Selecting Text— 53." The default is a tab with leader dots. You can use 
148
up to five characters, which must be enclosed in quotation marks. 
149
\s Identifier 
150
Includes a number such as a chapter number before the page number. The 
151
chapter or other item must be numbered with a SEQ field. Identifier must 
152
match the identifier in the SEQ field. For example, if you insert { SEQ 
153
chapter } before each chapter heading, { TOC \o "1-3" \s chapter } displays 
154
page numbers as 2-14, where "2" is the chapter number. 
155
\d "Separator" 
156
When used with the \s switch, specifies the number of characters that 
157
separate the sequence numbers and page numbers. Enclose the characters in 
158
quotation marks. Word uses a hyphen (-) if no \d switch is specified. In the 
159
table of contents generated by { TOC \o "1-3" \s chapter \d ":" }, a colon 
160
(:) separates chapter numbers and page numbers— for example, "2:14." 
161
\t "Style,Level, Style,Level,..." 
162
Builds a table of contents from paragraphs formatted with styles other than 
163
the built-in heading styles. For example, { TOC \t "chaptertitle,1, 
164
chapterhead,2" } builds a table of contents from paragraphs formatted with 
165
the styles "chaptertitle" and "chapterhead." The number after each style name 
166
indicates the table of contents entry level that corresponds to that style. 
167
You can use both the \o switch and the \t switch to build a table of 
168
contents from built-in heading styles and other styles.
169

    
170
\u 
171
Builds a table of contents by using the applied paragraph outline level 
172
(outline level: Paragraph formatting you can use to assign a hierarchical 
173
level (Level 1 through Level 9) to paragraphs in your document. For example, 
174
after you assign outline levels, you can work with the document in outline 
175
view or in the Document Map.). 
176
\w 
177
Preserves tab entries within table entries. 
178
\x 
179
Preserves newline characters within table entries. 
180
\z 
181
Hides tab leader and page numbers in Web layout view (Web layout view: A 
182
view of a document as it will appear in a Web browser. For example, the 
183
document appears as one long page (without page breaks) and text and tables 
184
wrap to fit in the window.).
185
-->
186
   </doc>
187
    <xsl:template name="tocSection">
188
        <divGen type="toc"/>
189
    </xsl:template>
190

    
191
    <xsl:template name="_tocSection">
192
      <xsl:variable name="typestring">
193
	<xsl:value-of select="(.//w:instrText)[1]"/>
194
      </xsl:variable>
195
	<xsl:message>TOC: test [<xsl:value-of select="$typestring"/>]</xsl:message>
196
    <xsl:analyze-string select='$typestring' regex='\s*([A-z]+)\s+(.*)\s+"([^,]+),(.*)"\s*'>
197
      <xsl:matching-substring>
198
	<xsl:message>TOC ok, found [<xsl:value-of select="regex-group(1)"/>][<xsl:value-of select="regex-group(2)"/>][<xsl:value-of select="regex-group(3)"/>]</xsl:message>
199
      </xsl:matching-substring>
200
      <xsl:non-matching-substring>
201
	<xsl:message>TOC panic on <xsl:value-of select="."/></xsl:message>
202
      </xsl:non-matching-substring>
203
    </xsl:analyze-string>
204
<!--
205
        <w:instrText xml:space="preserve"> TOC \o "1-2" \h \z \t "ITLP H3,3" </w:instrText>
206

    
207
        <w:instrText xml:space="preserve"> TOC \h \z \t "ITLP Ex Heading,2" </w:instrText>
208
-->
209
        <divGen type="toc"/>
210
    </xsl:template>
211
    
212
    
213
</xsl:stylesheet>