1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <xsl:stylesheet xmlns:saxon="http://saxon.sf.net/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" extension-element-prefixes="saxon" version="2.0"> |
---|
3 | <xsl:import href="util.xsl"/> |
---|
4 | <xsl:output method="text" indent="yes" saxon:byte-order-mark="yes"/> |
---|
5 | <!-- list the data elements whose spaces should be preserved |
---|
6 | it seems listing only the parent node doesn't work --> |
---|
7 | <xsl:preserve-space elements="decimal group list pattern currencyMatch surroundingMatch insertBetween"/> |
---|
8 | <xsl:strip-space elements="*"/> |
---|
9 | |
---|
10 | <xsl:template match="/"> |
---|
11 | <xsl:apply-templates/> |
---|
12 | </xsl:template> |
---|
13 | |
---|
14 | <!-- process ldml,numbers--> |
---|
15 | <xsl:template name="top" match="/ldml"> |
---|
16 | <xsl:choose> |
---|
17 | <xsl:when test="count(./alias)>0"> |
---|
18 | <!-- Handle Alias --> |
---|
19 | <xsl:for-each select="./alias"> |
---|
20 | <xsl:call-template name="alias_template"> |
---|
21 | <xsl:with-param name="templateToCall">top</xsl:with-param> |
---|
22 | <xsl:with-param name="source" select="@source"></xsl:with-param> |
---|
23 | <xsl:with-param name="xpath" select="@path"></xsl:with-param> |
---|
24 | </xsl:call-template> |
---|
25 | </xsl:for-each> |
---|
26 | </xsl:when> |
---|
27 | <xsl:otherwise> |
---|
28 | <!-- ldml --> |
---|
29 | <xsl:if test="name()='ldml'"> |
---|
30 | <!-- numbers --> |
---|
31 | <xsl:for-each select="numbers"> |
---|
32 | <xsl:result-document href="number.js" encoding="UTF-8"><!--<xsl:value-of select="codepoints-to-string(65279)"/>-->// generated from ldml/main/*.xml, xpath: ldml/numbers |
---|
33 | ({<xsl:call-template name="numbers"></xsl:call-template> |
---|
34 | }) |
---|
35 | </xsl:result-document> |
---|
36 | </xsl:for-each> |
---|
37 | </xsl:if> |
---|
38 | </xsl:otherwise> |
---|
39 | </xsl:choose> |
---|
40 | </xsl:template> |
---|
41 | |
---|
42 | <!-- process numbers--> |
---|
43 | <xsl:template name="numbers" match="numbers"> |
---|
44 | <xsl:choose> |
---|
45 | <xsl:when test="count(./alias)>0"> |
---|
46 | <!-- Handle Alias --> |
---|
47 | <xsl:for-each select="./alias"> |
---|
48 | <xsl:call-template name="alias_template"> |
---|
49 | <xsl:with-param name="templateToCall">numbers</xsl:with-param> |
---|
50 | <xsl:with-param name="source" select="@source"></xsl:with-param> |
---|
51 | <xsl:with-param name="xpath" select="@path"></xsl:with-param> |
---|
52 | </xsl:call-template> |
---|
53 | </xsl:for-each> |
---|
54 | </xsl:when> |
---|
55 | <xsl:otherwise> |
---|
56 | <xsl:apply-templates/> |
---|
57 | </xsl:otherwise> |
---|
58 | </xsl:choose> |
---|
59 | </xsl:template> |
---|
60 | |
---|
61 | <!-- process symbols --> |
---|
62 | <xsl:template name="symbols" match="symbols"> |
---|
63 | <xsl:choose> |
---|
64 | <xsl:when test="count(./alias)>0"> |
---|
65 | <!-- Handle Alias --> |
---|
66 | <xsl:for-each select="./alias"> |
---|
67 | <xsl:call-template name="alias_template"> |
---|
68 | <xsl:with-param name="templateToCall">symbols</xsl:with-param> |
---|
69 | <xsl:with-param name="source" select="@source"></xsl:with-param> |
---|
70 | <xsl:with-param name="xpath" select="@path"></xsl:with-param> |
---|
71 | </xsl:call-template> |
---|
72 | </xsl:for-each> |
---|
73 | </xsl:when> |
---|
74 | <xsl:otherwise> |
---|
75 | <xsl:for-each select="*[not(@draft)] | *[@draft!='provisional' and @draft!='unconfirmed']"> |
---|
76 | <xsl:call-template name="insert_comma"/> |
---|
77 | '<xsl:value-of select="name()"></xsl:value-of> |
---|
78 | <xsl:text>':"</xsl:text> |
---|
79 | <xsl:value-of select="replace(.,'"', '\\"')"></xsl:value-of> |
---|
80 | <xsl:text>"</xsl:text> |
---|
81 | <!--xsl:if test="count(following-sibling::*)>0 |
---|
82 | or count(parent::node()/following-sibling::*)>0"> |
---|
83 | <xsl:text>,</xsl:text> |
---|
84 | </xsl:if--> |
---|
85 | </xsl:for-each> |
---|
86 | </xsl:otherwise> |
---|
87 | </xsl:choose> |
---|
88 | </xsl:template> |
---|
89 | |
---|
90 | <!-- process decimalFormats | scientificFormats | percentFormats | currencyFormats --> |
---|
91 | <xsl:template name="formats" match="decimalFormats | scientificFormats | percentFormats | currencyFormats"> |
---|
92 | <xsl:param name="width" select="@type"></xsl:param> |
---|
93 | <xsl:choose> |
---|
94 | <xsl:when test="count(./alias)>0"> |
---|
95 | <!-- Handle Alias --> |
---|
96 | <xsl:for-each select="./alias"> |
---|
97 | <xsl:call-template name="alias_template"> |
---|
98 | <xsl:with-param name="templateToCall">formats</xsl:with-param> |
---|
99 | <xsl:with-param name="source" select="@source"></xsl:with-param> |
---|
100 | <xsl:with-param name="xpath" select="@path"></xsl:with-param> |
---|
101 | <xsl:with-param name="width" select="$width"></xsl:with-param> |
---|
102 | </xsl:call-template> |
---|
103 | </xsl:for-each> |
---|
104 | </xsl:when> |
---|
105 | <xsl:otherwise> |
---|
106 | <xsl:choose> |
---|
107 | <xsl:when test="contains(name(),'Formats')"> |
---|
108 | <xsl:for-each select="*"> |
---|
109 | <xsl:call-template name="formats"></xsl:call-template> |
---|
110 | </xsl:for-each> |
---|
111 | </xsl:when> |
---|
112 | <xsl:otherwise> |
---|
113 | <xsl:if test="name()!='default'"> |
---|
114 | <xsl:if test="name()='currencySpacing'"> |
---|
115 | <xsl:call-template name="currencySpacing"></xsl:call-template> |
---|
116 | </xsl:if><xsl:for-each select=".//pattern[not(@draft)] | |
---|
117 | .//pattern[@draft!='provisional' and @draft!='unconfirmed']"> |
---|
118 | <xsl:call-template name="insert_comma"/> |
---|
119 | '<xsl:value-of select="name(..)"></xsl:value-of> |
---|
120 | <xsl:if test="string-length($width)>0"> |
---|
121 | <xsl:text>-</xsl:text> |
---|
122 | <xsl:value-of select="$width"></xsl:value-of> |
---|
123 | </xsl:if> |
---|
124 | <xsl:text>':"</xsl:text><xsl:value-of select="replace(.,'"', '\\"')"/> |
---|
125 | <xsl:text>"</xsl:text> |
---|
126 | <!--xsl:if test="count(parent::node()/parent::node()/following-sibling::*)>0 |
---|
127 | or count(parent::node()/parent::node()/parent::node()/following-sibling::*)>0"> |
---|
128 | <xsl:text>,</xsl:text> |
---|
129 | </xsl:if--> |
---|
130 | </xsl:for-each> |
---|
131 | </xsl:if> |
---|
132 | </xsl:otherwise> |
---|
133 | </xsl:choose> |
---|
134 | </xsl:otherwise> |
---|
135 | </xsl:choose> |
---|
136 | </xsl:template> |
---|
137 | |
---|
138 | <!-- process currencySpacing --> |
---|
139 | <xsl:template name="currencySpacing"> |
---|
140 | <xsl:choose> |
---|
141 | <xsl:when test="count(./alias)>0"> |
---|
142 | <!-- Handle Alias --> |
---|
143 | <xsl:for-each select="./alias"> |
---|
144 | <xsl:call-template name="alias_template"> |
---|
145 | <xsl:with-param name="templateToCall">symbols</xsl:with-param> |
---|
146 | <xsl:with-param name="source" select="@source"></xsl:with-param> |
---|
147 | <xsl:with-param name="xpath" select="@path"></xsl:with-param> |
---|
148 | </xsl:call-template> |
---|
149 | </xsl:for-each> |
---|
150 | </xsl:when> |
---|
151 | <xsl:otherwise> |
---|
152 | <xsl:choose> |
---|
153 | <xsl:when test="name()='currencySpacing' |
---|
154 | or name()='beforeCurrency' |
---|
155 | or name()='afterCurrency'" > |
---|
156 | <xsl:for-each select="*"> |
---|
157 | <xsl:call-template name="currencySpacing"></xsl:call-template> |
---|
158 | </xsl:for-each> |
---|
159 | </xsl:when> |
---|
160 | <xsl:otherwise> |
---|
161 | <xsl:if test=".[(not(@draft) or @draft!='provisional' and @draft!='unconfirmed')]"> |
---|
162 | <xsl:call-template name="insert_comma"/> |
---|
163 | '<xsl:value-of select="name(../..)"></xsl:value-of> |
---|
164 | <xsl:text>-</xsl:text> |
---|
165 | <xsl:value-of select="name(..)"></xsl:value-of> |
---|
166 | <xsl:text>-</xsl:text> |
---|
167 | <xsl:value-of select="name()"></xsl:value-of> |
---|
168 | <xsl:text>':"</xsl:text> |
---|
169 | <xsl:value-of select="replace(.,'"', '\\"')"></xsl:value-of> |
---|
170 | <xsl:text>"</xsl:text> |
---|
171 | <!--xsl:if test="count(following-sibling::*)>0 |
---|
172 | or count(parent::node()/following-sibling::*)>0 |
---|
173 | or count(parent::node()/parent::node()/following-sibling::*)>0 |
---|
174 | or count(parent::node()/parent::node()/parent::node()/following-sibling::*)>0"> |
---|
175 | <xsl:text>,</xsl:text> |
---|
176 | </xsl:if--> |
---|
177 | </xsl:if> |
---|
178 | </xsl:otherwise> |
---|
179 | </xsl:choose> |
---|
180 | </xsl:otherwise> |
---|
181 | </xsl:choose> |
---|
182 | </xsl:template> |
---|
183 | |
---|
184 | <xsl:template name="ignore" match="defaultNumberingSystem | otherNumberingSystems | currencies"></xsl:template> |
---|
185 | |
---|
186 | <!-- too bad that can only use standard xsl:call-template(name can not be variable) |
---|
187 | error occurs if use <saxson:call-templates($templateToCall) /> --> |
---|
188 | <xsl:template name="invoke_template_by_name"> |
---|
189 | <xsl:param name="templateName"></xsl:param> |
---|
190 | <xsl:param name="name"></xsl:param> |
---|
191 | <xsl:param name="width"></xsl:param> |
---|
192 | <xsl:param name="ctx"></xsl:param> |
---|
193 | <xsl:param name="fromLocaleAlias"></xsl:param> |
---|
194 | <xsl:if test="$templateName='top'"> |
---|
195 | <xsl:call-template name="top"></xsl:call-template> |
---|
196 | </xsl:if> |
---|
197 | <xsl:if test="$templateName='numbers'"> |
---|
198 | <xsl:call-template name="numbers"></xsl:call-template> |
---|
199 | </xsl:if> |
---|
200 | <xsl:if test="$templateName='symbols'"> |
---|
201 | <xsl:call-template name="symbols"></xsl:call-template> |
---|
202 | </xsl:if> |
---|
203 | <xsl:if test="$templateName='formats'"> |
---|
204 | <xsl:call-template name="formats"> |
---|
205 | <xsl:with-param name="width" select="$width"></xsl:with-param> |
---|
206 | </xsl:call-template> |
---|
207 | </xsl:if> |
---|
208 | <xsl:if test="$templateName='currencySpacing'"> |
---|
209 | <xsl:call-template name="currencySpacing"></xsl:call-template> |
---|
210 | </xsl:if> |
---|
211 | </xsl:template> |
---|
212 | </xsl:stylesheet> |
---|