-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathadd-alias.xsl
42 lines (36 loc) · 1.14 KB
/
add-alias.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
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="aliases" select="doc('aliases.xml')"/>
<xsl:output encoding="US-ASCII" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:processing-instruction name="xml-stylesheet">type="text/xsl" href="unicode.xsl"</xsl:processing-instruction>
<xsl:text> </xsl:text>
<xsl:copy-of select="comment()"/>
<xsl:text> </xsl:text>
<xsl:apply-templates/>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="processing-instruction()|comment()" priority="2"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:key name="alias" match="tr" use="concat(
'U',
if(string-length(td/a)=4) then '0' else '',
td/a)
"/>
<xsl:template match="unicodedata">
<xsl:copy>
<xsl:copy-of select="@* except @alias"/>
<xsl:if test="key('alias',../@id,$aliases)">
<xsl:attribute name="alias"
select="string-join(
key('alias',../@id,$aliases)/td[1],';'
)">
</xsl:attribute>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>