-
Notifications
You must be signed in to change notification settings - Fork 11
/
charmap.xsl
220 lines (184 loc) · 7.41 KB
/
charmap.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:strip-space elements="group"/>
<xsl:output
method="xml" indent="no" encoding="US-ASCII" omit-xml-declaration="yes"
/>
<xsl:variable name="top"> produced by the XSL script charmap.xsl
from input data in unicode.xml.
Copyright 2003 - 2013 W3C.
Use and distribution of this code are permitted under the terms of the
W3C Software Notice and License.
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.html
Please report any errors to David Carlisle
via the public W3C list [email protected].
The numeric character values assigned to each entity
(should) match the Unicode assignments in Unicode 5.2.
</xsl:variable>
<xsl:variable name="copy">
Entity names in this file are derived from files carrying the
following notice:
(C) International Organization for Standardization 19XY
Permission to copy in any form is granted for use with
conforming SGML systems and applications as defined in
ISO 8879, provided this notice is included in all copies.
</xsl:variable>
<xsl:template match="set">
<xsl:variable name="d" select="../@name"/>
<xsl:variable name="f">
<xsl:choose>
<xsl:when test="starts-with(@name,'957')"><xsl:value-of select="substring(@name,11)"/></xsl:when>
<xsl:when test="starts-with(@name,'88')"><xsl:value-of select="substring-after(@name,'-')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:text> </xsl:text>
<xsl:element name="xsl:import">
<xsl:attribute name="href"><xsl:value-of select="$f"/>map.xsl</xsl:attribute>
</xsl:element>
<xsl:result-document href="{$d}/{$f}map.xsl">
<xsl:text> </xsl:text>
<xsl:comment>
<xsl:text> File </xsl:text>
<xsl:value-of select="$f"/>map.xsl<xsl:text/>
<xsl:copy-of select="$top"/>
<xsl:choose>
<xsl:when test="starts-with(@name,'9573') and replace(@name,'2003','1991')=../../group[@name='iso9573-1991']/set/@name">
<xsl:value-of select="translate($copy,'XY','86')"/>
</xsl:when>
<xsl:when test="starts-with(@name,'9')">
<xsl:value-of select="translate($copy,'XY','91')"/>
</xsl:when>
<xsl:when test="starts-with(@name,'8')">
<xsl:value-of select="translate($copy,'XY','86')"/>
</xsl:when>
</xsl:choose>
</xsl:comment>
<xsl:text> </xsl:text>
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">2.0</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="xsl:character-map">
<xsl:attribute name="name"><xsl:value-of select="$f"/></xsl:attribute>
<xsl:for-each select="key('set',@name)">
<xsl:sort lang="en" select="@id"/>
<xsl:sort lang="en" select="not(@optional)"/>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="not(contains(../@id,'-') or ../@dec < 128)">
<xsl:element name="xsl:output-character">
<xsl:attribute name="character">
<xsl:value-of select="codepoints-to-string(../@dec)"/>
</xsl:attribute>
<xsl:attribute name="string">
<xsl:text>&</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>;</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:comment>
<xsl:value-of select="../@id"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@id"/>
</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text> </xsl:text>
</xsl:element>
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
</xsl:element>
<xsl:text> </xsl:text>
</xsl:result-document>
</xsl:template>
<xsl:key name="set" match="entity" use="@set"/>
<xsl:template match="/">
<xsl:apply-templates select="unicode/entitygroups/group[@name='2007']"/>
</xsl:template>
<xsl:template match="group[@name='predefined']"/>
<xsl:template match="group">
<xsl:result-document href="{@name}/entitynamesmap.xsl">
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">2.0</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:comment>
<xsl:text> entitynamesmap.xsl</xsl:text>
<xsl:copy-of select="$top"/>
<xsl:text> </xsl:text>
</xsl:comment>
<xsl:text> </xsl:text>
<xsl:apply-templates select="set"/>
<xsl:text> </xsl:text>
<xsl:element name="xsl:character-map">
<xsl:attribute name="name">
<xsl:value-of select="if(@name='2007') then 'w3c-entity-names' else @name"/>
</xsl:attribute>
<xsl:attribute name="use-character-maps">
<xsl:for-each select="set">
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="starts-with(@name,'957')"><xsl:value-of select="substring(@name,11)"/></xsl:when>
<xsl:when test="starts-with(@name,'88')"><xsl:value-of select="substring-after(@name,'-')"/></xsl:when>
<xsl:when test="@name='html5-uppercase'"><xsl:value-of select="@name"/></xsl:when>
<xsl:when test="starts-with(@name,'html')"><xsl:value-of select="substring-after(@name,'-')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:attribute>
</xsl:element>
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
</xsl:element>
<xsl:text> </xsl:text>
</xsl:result-document>
<xsl:result-document href="{@name}/htmlmathml.xsl">
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">2.0</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:comment>
<xsl:text> htmlmathml.xsl</xsl:text>
<xsl:copy-of select="$top"/>
<xsl:text> </xsl:text>
</xsl:comment>
<xsl:text> </xsl:text>
<xsl:for-each select="set[@name=../../group[@name=('mathml','html5')]/set/@name]">
<xsl:variable name="d" select="../@name"/>
<xsl:variable name="f">
<xsl:choose>
<xsl:when test="starts-with(@name,'957')"><xsl:value-of select="substring(@name,11)"/></xsl:when>
<xsl:when test="starts-with(@name,'88')"><xsl:value-of select="substring-after(@name,'-')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:text> </xsl:text>
<xsl:element name="xsl:import">
<xsl:attribute name="href"><xsl:value-of select="$f"/>map.xsl</xsl:attribute>
</xsl:element>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:element name="xsl:character-map">
<xsl:attribute name="name" select="'htmlmathml'"/>
<xsl:attribute name="use-character-maps">
<xsl:for-each select="set[@name=../../group[@name=('mathml','html5')]/set/@name]">
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="starts-with(@name,'957')"><xsl:value-of select="substring(@name,11)"/></xsl:when>
<xsl:when test="starts-with(@name,'88')"><xsl:value-of select="substring-after(@name,'-')"/></xsl:when>
<xsl:when test="@name='html5-uppercase'"><xsl:value-of select="@name"/></xsl:when>
<xsl:when test="starts-with(@name,'html')"><xsl:value-of select="substring-after(@name,'-')"/></xsl:when>
<xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:attribute>
</xsl:element>
<xsl:text> </xsl:text>
<xsl:text> </xsl:text>
</xsl:element>
<xsl:text> </xsl:text>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>