This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
generate.xsl
188 lines (184 loc) · 6.89 KB
/
generate.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?xml version="1.0" encoding="utf-8"?>
<XSL:stylesheet xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:xsl="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:n="www.example.com"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:XSL="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="XSL xsl skos rng tei n" xpath-default-namespace="http://www.tei-c.org/ns/1.0" version="2.0">
<XSL:output indent="yes"/>
<XSL:namespace-alias stylesheet-prefix="xsl" result-prefix="XSL"/>
<XSL:template match="/">
<XSL:result-document href="headeronly.xml">
<constraintSpec ident="headeronlyelement" scheme="isoschematron">
<constraint>
<rule
xmlns="http://purl.oclc.org/dsdl/schematron">
<XSL:attribute name="context">
<XSL:text>tei:</XSL:text>
<XSL:value-of select="(//row[ position()>1 and
not(cell[1]='')
and cell[10] =
'header']/cell[1])"
separator=" | tei:"/>
</XSL:attribute>
<report test="ancestor::tei:text">Error: The element <name/> is not permitted outside the header</report>
</rule>
</constraint>
</constraintSpec>
</XSL:result-document>
<XSL:result-document href="headerelements.xml">
<specGrp xml:id="header">
<moduleRef key="header"/>
<XSL:for-each select="//row[ position()>1 and
not(cell[1]='') and cell[10] = 'header']/cell[1]">
<elementRef key="{.}"/>
</XSL:for-each>
</specGrp>
</XSL:result-document>
<XSL:result-document href="elementsummary.xml">
<div>
<head>Summary</head>
<!--
1. element
2. eebo
3. Tite
4. TEI Lite
5 .OTAnrs
6. OTA
7. DTAnrs
8. dta
9. use
10. group
11. action
-->
<p>A total of <XSL:value-of select="count(//row[ position()>1 and not(cell[1]='') and not(cell[10] = 'header') and not(normalize-space(cell[10]) = '') ])"/> elements are selected for use in
the <gi>text</gi> part of a document; an additional
<XSL:value-of select="count(//row[ position()>1 and
not(cell[1]='') and cell[10] = 'header'])"/>
elements are allowed for in the header. The following table
shows the usage of all elements in six existing corpora, and
classifies them 11 usage groups. There are
<XSL:value-of select="count(//row[ position()>1 and
normalize-space(cell[10]) = ''])"/> elements
listed which are <emph>not</emph> allowed in TEI Simple, but should be transformed
to another element.</p>
<XSL:variable name="corpses" select="distinct-values(doc('auxiliary/count.xml')//elementRef/@corpus)"/>
<table>
<row role="label">
<cell>Element</cell>
<XSL:for-each select="$corpses">
<cell>
<XSL:value-of select="."/>
</cell>
</XSL:for-each>
<cell>Group</cell>
<cell>Use instead</cell>
</row>
<XSL:for-each select="//row[position()>1 and not(cell[1]='')]">
<XSL:sort select="cell[1]"/>
<row>
<XSL:variable name="e" select="normalize-space(cell[1])"/>
<cell>
<XSL:value-of select="$e"/>
</cell>
<XSL:for-each select="$corpses">
<XSL:variable name="c" select="."/>
<cell rend="right">
<XSL:value-of
select="format-number(number(sum(doc('auxiliary/count.xml')//elementRef[@key=$e
and @corpus=$c]/@count)),'########')"/>
</cell>
</XSL:for-each>
<XSL:copy-of select="cell[10]"/>
<cell><XSL:if test="normalize-space(cell[11]) !=''">
<gi><XSL:value-of select="normalize-space(cell[11])"/></gi>
</XSL:if>
</cell>
</row>
</XSL:for-each>
</table>
<list type="gloss">
<XSL:for-each-group select="//row[position()>1 and not(cell[1]='')]" group-by="normalize-space(cell[10])">
<XSL:sort select="normalize-space(cell[10])"/>
<XSL:sort select="cell[1]"/>
<XSL:choose>
<XSL:when test="current-grouping-key()=''"/>
<XSL:otherwise>
<label>
<XSL:value-of select="current-grouping-key()"/>
</label>
<item>
<XSL:for-each select="current-group()">
<gi>
<XSL:value-of select="normalize-space(cell[1])"/>
</gi>
<XSL:text> </XSL:text>
</XSL:for-each>
</item>
</XSL:otherwise>
</XSL:choose>
</XSL:for-each-group>
</list>
</div>
</XSL:result-document>
<XSL:result-document href="simpleelements.xml">
<specGrp xml:id="simpleelements">
<XSL:for-each select="//row[position()>1 and not(cell[1]='')]">
<XSL:choose>
<XSL:when test="contains(cell[10],'header')">
<XSL:message>header element <XSL:value-of select="cell[1]"/></XSL:message>
</XSL:when>
<XSL:when test="normalize-space(cell[10])=''"/>
<XSL:otherwise>
<XSL:message>text element <XSL:value-of select="cell[1]"/></XSL:message>
<elementRef key="{normalize-space(cell[1])}"/>
</XSL:otherwise>
</XSL:choose>
</XSL:for-each>
</specGrp>
</XSL:result-document>
<XSL:result-document href="mapatts.xsl">
<xsl:stylesheet version="2.0">
<XSL:for-each-group
select="doc('odd/teisimple.odd')//attDef[.//processing-instruction()[name()='exactMatch']]"
group-by="@ident">
<XSL:variable name="att" select="current-grouping-key()"/>
<xsl:template mode="pass2 #default" match="@{if ($att='rendition') then 'rend' else $att}">
<xsl:attribute name="{$att}">
<xsl:choose>
<XSL:for-each select=".//processing-instruction()[name()='exactMatch']">
<XSL:variable name="val" select="parent::valItem/@ident"/>
<xsl:when>
<XSL:attribute name="test">
<XSL:text>.='</XSL:text>
<XSL:value-of select="."/>
<XSL:text>'</XSL:text>
</XSL:attribute>
<XSL:value-of select="$val"/>
</xsl:when>
</XSL:for-each>
<xsl:otherwise>
<XSL:choose>
<XSL:when test="$att='rendition'">
<xsl:for-each select="tokenize(.,' ')">
<xsl:text>simple:</xsl:text>
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</XSL:when>
<XSL:otherwise>
<xsl:value-of select="."/>
</XSL:otherwise>
</XSL:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:template>
</XSL:for-each-group>
</xsl:stylesheet>
</XSL:result-document>
</XSL:template>
</XSL:stylesheet>