source: Dev/trunk/src/client/util/buildscripts/cldr/currency.xsl @ 483

Last change on this file since 483 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 5.6 KB
Line 
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="displayName symbol"/>
8<xsl:strip-space elements="*"/>
9
10<!--  currencyList is an external string property like "AUD|BEF|CAD|CHF|CNY|DEM|...|USD",
11        if it is provided, only those currencies in this list will be extracted,
12        otherwise all the currencies will be extracted by default-->
13<xsl:param name="currencyList"></xsl:param>
14
15<xsl:template match="/">
16     <xsl:apply-templates/>
17</xsl:template>
18
19<!-- process ldml, numbers and currencies -->
20<xsl:template name="top" match="/ldml">
21    <xsl:choose>
22        <xsl:when test="count(./alias)>0">
23            <!-- Handle Alias -->
24            <xsl:for-each select="./alias">
25                <xsl:call-template name="alias_template">
26                    <xsl:with-param name="templateToCall">top</xsl:with-param>
27                    <xsl:with-param name="source" select="@source"></xsl:with-param>
28                    <xsl:with-param name="xpath" select="@path"></xsl:with-param>
29                </xsl:call-template>     
30                </xsl:for-each>
31        </xsl:when>
32        <xsl:otherwise>
33            <xsl:choose>
34                <xsl:when test="name()='currencies'">
35                    <xsl:result-document href="currency.js" encoding="UTF-8">// generated from ldml/main/*.xml, xpath: ldml/numbers/currencies
36({<xsl:choose><xsl:when test="string-length(string($currencyList))>0 and string($currencyList)!='${currencies}'">
37<!--if outer param $currencyList is not initiated, it will be '${currencies}' by default,please see ${util}/buildscripts/cldr/build.xml -->
38                                 <xsl:for-each select="currency">
39                                     <xsl:if test="contains($currencyList,@type)">
40                                         <xsl:call-template name="currency"></xsl:call-template>
41                                     </xsl:if>
42                                 </xsl:for-each>
43                         </xsl:when>
44                         <xsl:otherwise>
45                             <xsl:for-each select="currency">
46                                 <xsl:call-template name="currency"></xsl:call-template>                       
47                             </xsl:for-each>
48                         </xsl:otherwise>
49                     </xsl:choose>
50})
51                 </xsl:result-document>
52                </xsl:when>
53                <xsl:otherwise>
54                    <xsl:if test="name()='ldml'">
55                        <!-- ldml -->
56                        <xsl:for-each select="numbers">   
57                            <xsl:call-template name="top"></xsl:call-template>
58                        </xsl:for-each>
59                    </xsl:if>
60                    <xsl:if test="name()='numbers'">
61                        <!-- numbers -->
62                        <xsl:for-each select="currencies">
63                            <xsl:call-template name="top"></xsl:call-template>
64                        </xsl:for-each>
65                    </xsl:if>                 
66                </xsl:otherwise>
67            </xsl:choose>
68         </xsl:otherwise>
69    </xsl:choose>       
70</xsl:template>
71
72    <!-- currency-->
73    <xsl:template name="currency" match="currency">
74    <xsl:param name="width" select="@type"></xsl:param>
75    <xsl:choose>
76        <xsl:when test="count(./alias)>0">
77            <!-- Handle Alias -->
78            <xsl:for-each select="./alias">
79                <xsl:call-template name="alias_template">
80                    <xsl:with-param name="templateToCall">currency</xsl:with-param>
81                    <xsl:with-param name="source" select="@source"></xsl:with-param>
82                    <xsl:with-param name="xpath" select="@path"></xsl:with-param>
83                </xsl:call-template>
84            </xsl:for-each>
85        </xsl:when>
86        <xsl:otherwise>
87        <!-- CLDR 1.6+: skip entries in the form of displayName count="" until we implement plurals -->
88            <xsl:for-each select="*[not(@count) and (not(@draft) or (@draft!='provisional' and @draft!='unconfirmed'))]">
89                                <xsl:call-template name="insert_comma"/>
90                <xsl:text>
91        </xsl:text>
92                        <xsl:value-of select="$width"></xsl:value-of>
93                <xsl:text>_</xsl:text>
94                <xsl:value-of select="name()"></xsl:value-of>
95                <xsl:text>:"</xsl:text>
96                <xsl:value-of select="replace(.,'&quot;', '\\&quot;')"></xsl:value-of>
97                <xsl:text>"</xsl:text>
98            </xsl:for-each>
99         </xsl:otherwise>
100        </xsl:choose>
101    </xsl:template>
102
103    <!-- too bad that can only use standard xsl:call-template(name can not be variable)
104         error occurs if use <saxson:call-templates($templateToCall)  /> -->
105    <xsl:template name="invoke_template_by_name">
106        <xsl:param name="templateName"></xsl:param>
107        <xsl:param name="name"></xsl:param>
108        <xsl:param name="width"></xsl:param>
109                <xsl:param name="ctx"></xsl:param>
110                <xsl:param name="fromLocaleAlias"></xsl:param>
111        <xsl:if test="$templateName='top'">
112            <xsl:call-template name="top"></xsl:call-template>
113        </xsl:if>
114        <xsl:if test="$templateName='currency'">
115            <xsl:call-template name="currency"></xsl:call-template>
116        </xsl:if>
117    </xsl:template>
118</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.