2
<xsl:stylesheet version="1.0"
3
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
xmlns:saxon="http://icl.com/saxon"
5
extension-element-prefixes="saxon"
6
xmlns:t="http://www.thaiopensource.com/ns/annotations"
7
xmlns:a="http://relaxng.org/ns/compatibility/annotations/0.9"
8
xmlns="http://relaxng.org/ns/structure/0.9">
10
<xsl:import href="dtdinst2rng.xsl"/>
12
<xsl:output indent="yes" encoding="iso-8859-1"/>
14
<xsl:param name="out-suffix" select="'.rng'"/>
15
<xsl:param name="element-prefix" select="''"/>
16
<xsl:param name="attlist-prefix" select="'al.'"/>
18
<xsl:key name="override" match="overridden[not(duplicate)]" use="*/@name"/>
20
<xsl:template match="doctype">
21
<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
<xsl:apply-templates/>
26
<xsl:template match="modelGroup|datatype">
27
<define name="{@name}">
28
<xsl:if test="key('override',@name)">
29
<xsl:call-template name="condition"/>
31
<xsl:apply-templates/>
35
<xsl:template match="attributeGroup">
36
<define name="{@name}">
37
<xsl:if test="not(*)">
40
<xsl:apply-templates/>
44
<xsl:template match="default|fixed|implied" mode="required">
45
<xsl:param name="content"/>
47
<xsl:for-each select="ancestor::attributeGroup">
48
<xsl:if test="key('override',@name)">
49
<xsl:call-template name="condition"/>
52
<xsl:copy-of select="$content"/>
56
<xsl:template match="attributeDefaultRef[@name='INHERITED']"
58
<xsl:attribute name="t:inherited">true</xsl:attribute>
61
<xsl:template match="flag">
62
<xsl:if test="starts-with(@name,'TEI.')
64
and @name != 'TEI.general'
65
and @name != 'TEI.singleBase'">
66
<define name="{@name}">
67
<xsl:apply-templates/>
72
<!-- Define the marked section keywords as ignore in teikey2. -->
73
<xsl:template match="overridden[flag[starts-with(@name,'TEI.')
74
and not(@name='TEI.XML')
75
and not(@name='TEI.general')
77
<define name="{flag/@name}">
82
<xsl:template match="externalIdRef">
83
<xsl:variable name="f"
84
select="concat(key('param',@name)/@system,$out-suffix)"/>
85
<include href="{$f}"/>
86
<saxon:output href="{$f}">
87
<grammar datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
88
<xsl:if test="$f = concat('tei2.dtd', $out-suffix)">
89
<xsl:call-template name="main"/>
91
<xsl:if test="$f = concat('teikey2.ent', $out-suffix)">
92
<xsl:call-template name="key"/>
94
<xsl:apply-templates/>
99
<xsl:template match="element">
100
<xsl:variable name="name">
101
<xsl:apply-templates select="*[1]"/>
103
<define name="{$element-prefix}{$name}">
104
<xsl:call-template name="condition"/>
105
<element name="{$name}">
106
<ref name="{$attlist-prefix}{$name}"/>
107
<xsl:apply-templates select="*[2]"/>
112
<xsl:template name="condition">
113
<xsl:variable name="flag"
114
select="ancestor::includedSection[starts-with(@flag,'TEI.')
116
and @flag != 'TEI.mixed'
117
and @flag != 'TEI.general'
118
and @flag != 'TEI.singleBase'][1]/@flag"/>
119
<xsl:if test="$flag">
120
<ref name="{$flag}"/>
124
<!-- This puts the definition of gram in the 'right' place (in the
125
dictonaries module. -->
127
<xsl:template match="ignoredSection[@flag='gram'][ancestor::externalIdRef[@name='TEI.dictionaries.dtd']]">
128
<xsl:apply-templates select="//element[nameSpecRef[@name='n.gram']]"/>
129
<xsl:apply-templates select="//attlist[nameSpecRef[@name='n.gram']]"/>
132
<!-- This makes things work when TEI.mixed is turned on. -->
134
<xsl:template match="ignoredSection[@flag='TEI.mixed'
135
and contains(., 'component')]">
139
<xsl:value-of select="substring-before(substring-after(.,'<!--'),'-->')"/>
141
<define name="component" combine="choice">
142
<ref name="TEI.mixed"/>
143
<xsl:apply-templates select="key('param','component')/*"/>
147
<xsl:template name="main">
151
<ref name="teiCorpus.2"/>
154
<define name="TEI...end"><notAllowed/></define>
155
<define name="dictScrap"><notAllowed/></define>
156
<define name="att" combine="choice"><notAllowed/></define>
157
<define name="gi" combine="choice"><notAllowed/></define>
158
<define name="tag" combine="choice"><notAllowed/></define>
159
<define name="val" combine="choice"><notAllowed/></define>
162
<xsl:template name="key">
163
<define name="IGNORE"><notAllowed/></define>
164
<define name="INCLUDE"><empty/></define>
167
<xsl:template match="include">
168
<ref name="INCLUDE"/>
171
<xsl:template match="ignore">