Changeset 7906

Show
Ignore:
Timestamp:
04/02/07 06:50:55 (20 months ago)
Author:
peller
Message:

Refactor xslt utilities, generate localization json at dojo._cldr. Refs #2624

Location:
util/trunk/buildscripts/cldr
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • util/trunk/buildscripts/cldr/build.xml

    r7897 r7906  
    1414        <property name="currencies" value="GBP,USD,CAD,AUD,EUR,CHF,HKD,JPY"/>   <!-- FIXME: arbitrary list. Property can be altered or eliminated to build all currencies --> 
    1515        <property name="ldml" location="ldml"/> 
    16         <property name="json" location="${root}/dojo/cldr/nls"/> 
     16        <property name="json" location="${root}/dojo/_cldr/nls"/> 
    1717 
    1818        <!-- -check-config task --> 
     
    155155                        <attribute name="basedir"/> 
    156156                        <attribute name="destdir"/> 
    157  
    158157                        <sequential> 
    159158                                <xslt includes="@{in}" style="@{style}" destdir="@{destdir}" basedir="@{basedir}" extension=".tmp"> 
     
    162161                                                <catalogpath path="ldml/catalog" /> 
    163162                                        </xmlcatalog> 
     163                                        <param name="basedir" expression="@{basedir}/" /> 
    164164                                        <param name="currencyList" expression="${currencies}" /> 
    165165                                </xslt> 
  • util/trunk/buildscripts/cldr/calendar.xsl

    r7897 r7906  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<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"/> 
    34<xsl:output method="text" indent="yes"/> 
    45<!-- list the data elements whose spaces should be preserved 
     
    78<xsl:strip-space elements="*"/>  
    89 
    9 <xsl:variable name="first" select="true()" saxon:assignable="yes"/> 
    10      
    1110<xsl:template match="/"> 
    1211     <xsl:apply-templates/> 
     
    453452</xsl:template> 
    454453     
    455 <!-- Sub output routine--> 
    456 <xsl:variable name="vLowercaseChars_CONST" select="'abcdefghijklmnopqrstuvwxyz'"/>  
    457 <xsl:variable name="vUppercaseChars_CONST" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> 
    458 <xsl:template name="camel_case"> 
    459     <xsl:param name="name"></xsl:param> 
    460     <xsl:variable name="words" select="tokenize($name, '-')"></xsl:variable> 
    461     <xsl:for-each select="$words"> 
    462         <xsl:choose> 
    463             <xsl:when test="position()=1"> 
    464                 <xsl:value-of select="."/> 
    465             </xsl:when> 
    466             <xsl:otherwise> 
    467                 <xsl:value-of select="translate(substring(., 1, 1), $vLowercaseChars_CONST, $vUppercaseChars_CONST)"/><xsl:value-of select="substring(., 2)"/> 
    468             </xsl:otherwise> 
    469         </xsl:choose> 
    470     </xsl:for-each> 
    471 </xsl:template> 
    472  
    473 <!-- recursive process for alias --> 
    474 <xsl:template name="alias_template"> 
    475     <xsl:param name="templateToCall"></xsl:param> 
    476     <xsl:param name="source"></xsl:param> 
    477     <xsl:param name="xpath"></xsl:param> 
    478      
    479     <xsl:variable name="cur_name" select="../name()"></xsl:variable> 
    480     <xsl:variable name="cur_width" select="../@type"></xsl:variable> 
    481      
    482     <xsl:choose> 
    483         <!-- source="locale" --> 
    484         <xsl:when test="$source='locale'"> 
    485             <xsl:for-each select="saxon:evaluate(concat('../',$xpath))">    
    486                 <xsl:call-template name="invoke_template_by_name"> 
    487                     <xsl:with-param name="templateName" select="$templateToCall"></xsl:with-param> 
    488                     <xsl:with-param name="name" select="$cur_name"></xsl:with-param> 
    489                     <xsl:with-param name="width" select="$cur_width"></xsl:with-param> 
    490                 </xsl:call-template> 
    491             </xsl:for-each> 
    492         </xsl:when> 
    493         <xsl:otherwise> 
    494             <!-- source is an external xml file --> 
    495             <xsl:if test="string-length($xpath)>0"> 
    496                 <xsl:for-each select="doc(concat('ldml/core/main/',concat($source,'.xml')))">  
    497                     <xsl:for-each select="saxon:evaluate($xpath)"> 
    498                        <xsl:call-template name="invoke_template_by_name"> 
    499                            <xsl:with-param name="templateName" select="$templateToCall"></xsl:with-param> 
    500                            <xsl:with-param name="name" select="$cur_name"></xsl:with-param> 
    501                            <xsl:with-param name="width" select="$cur_width"></xsl:with-param> 
    502                        </xsl:call-template> 
    503                   </xsl:for-each> 
    504                 </xsl:for-each> 
    505             </xsl:if>             
    506         </xsl:otherwise> 
    507     </xsl:choose> 
    508 </xsl:template>    
    509      
    510454  <!-- too bad that can only use standard xsl:call-template(name can not be variable)  
    511455         error occurs if use <saxson:call-templates($templateToCall)  /> --> 
     
    549493     </xsl:if>      
    550494 </xsl:template> 
    551      
    552 <xsl:template name="insert_comma"> 
    553     <xsl:choose> 
    554         <xsl:when test="$first"> 
    555             <saxon:assign name="first" select="false()"/> 
    556         </xsl:when> 
    557         <xsl:otherwise> 
    558             <xsl:text>,</xsl:text> 
    559         </xsl:otherwise> 
    560     </xsl:choose> 
    561 </xsl:template> 
    562      
    563495</xsl:stylesheet> 
  • util/trunk/buildscripts/cldr/currency.xsl

    r7897 r7906  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<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"/> 
    34<xsl:output method="text" indent="yes"/> 
    45<!-- list the data elements whose spaces should be preserved 
     
    1112        otherwise all the currencies will be extracted by default--> 
    1213<xsl:param name="currencyList"></xsl:param> 
    13 <xsl:variable name="first" select="true()" saxon:assignable="yes"/> 
    1414 
    1515<xsl:template match="/"> 
     
    105105        </xsl:choose> 
    106106    </xsl:template> 
    107      
    108     <!-- recursive process for alias --> 
    109     <xsl:template name="alias_template"> 
    110         <xsl:param name="templateToCall"></xsl:param> 
    111         <xsl:param name="source"></xsl:param> 
    112         <xsl:param name="xpath"></xsl:param> 
    113         <xsl:variable name="cur_width" select="../@type"></xsl:variable> 
    114          
    115         <xsl:choose>             
    116             <xsl:when test="compare($source,'locale')=0"> 
    117                 <!-- source="locale" --> 
    118                 <xsl:for-each select="saxon:evaluate(concat('../',$xpath))">    
    119                     <xsl:call-template name="invoke_template_by_name"> 
    120                         <xsl:with-param name="templateName" select="$templateToCall"></xsl:with-param> 
    121                     </xsl:call-template> 
    122                 </xsl:for-each> 
    123             </xsl:when> 
    124             <xsl:otherwise> 
    125                 <!-- source is an external xml file --> 
    126                 <xsl:if test="string-length($xpath)>0"> 
    127                         <xsl:for-each select="doc(concat('ldml/core/main/',concat($source,'.xml')))">  
    128                         <xsl:for-each select="saxon:evaluate($xpath)"> 
    129                             <xsl:call-template name="invoke_template_by_name"> 
    130                                 <xsl:with-param name="templateName" select="$templateToCall"></xsl:with-param> 
    131                             </xsl:call-template> 
    132                         </xsl:for-each> 
    133                     </xsl:for-each> 
    134                 </xsl:if>             
    135             </xsl:otherwise> 
    136         </xsl:choose> 
    137     </xsl:template>    
    138      
     107 
    139108    <!-- too bad that can only use standard xsl:call-template(name can not be variable)  
    140109         error occurs if use <saxson:call-templates($templateToCall)  /> --> 
    141110    <xsl:template name="invoke_template_by_name"> 
    142111        <xsl:param name="templateName"></xsl:param> 
     112        <xsl:param name="name"></xsl:param>  
     113        <xsl:param name="width"></xsl:param> 
    143114        <xsl:if test="$templateName='top'"> 
    144115            <xsl:call-template name="top"></xsl:call-template> 
     
    148119        </xsl:if> 
    149120    </xsl:template>    
    150  
    151     <xsl:template name="insert_comma"> 
    152         <xsl:choose> 
    153             <xsl:when test="$first"> 
    154                 <saxon:assign name="first" select="false()"/> 
    155             </xsl:when> 
    156             <xsl:otherwise> 
    157                 <xsl:text>,</xsl:text> 
    158             </xsl:otherwise> 
    159         </xsl:choose> 
    160     </xsl:template> 
    161      
    162121</xsl:stylesheet> 
  • util/trunk/buildscripts/cldr/number.xsl

    r7897 r7906  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<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"/> 
    34<xsl:output method="text" indent="yes"/> 
    45<!-- list the data elements whose spaces should be preserved 
     
    67<xsl:preserve-space elements="decimal group list pattern currencyMatch surroundingMatch insertBetween"/> 
    78<xsl:strip-space elements="*"/>  
    8  
    9 <xsl:variable name="first" select="true()" saxon:assignable="yes"/> 
    109 
    1110<xsl:template match="/"> 
     
    178177      </xsl:choose> 
    179178</xsl:template> 
    180      
     179 
    181180<xsl:template name="currencies" match="currencies"></xsl:template> 
    182181 
    183 <!-- recursive process for alias --> 
    184 <xsl:template name="alias_template"> 
    185     <xsl:param name="templateToCall"></xsl:param> 
    186     <xsl:param name="source"></xsl:param> 
    187     <xsl:param name="xpath"></xsl:param> 
    188  
    189      <xsl:variable name="cur_width" select="../@type"></xsl:variable> 
    190    
    191     <xsl:choose> 
    192         <!-- source="locale" --> 
    193         <xsl:when test="$source='locale'"> 
    194             <xsl:for-each select="saxon:evaluate(concat('../',$xpath))">    
    195                 <xsl:call-template name="invoke_template_by_name"> 
    196                     <xsl:with-param name="templateName" select="$templateToCall"></xsl:with-param> 
    197                     <xsl:with-param name="width" select="$cur_width"></xsl:with-param> 
    198                 </xsl:call-template> 
    199             </xsl:for-each> 
    200         </xsl:when> 
    201         <xsl:otherwise> 
    202             <!-- source is an external xml file --> 
    203             <xsl:if test="string-length($xpath)>0"> 
    204                 <xsl:for-each select="doc(concat('ldml/core/main/',concat($source,'.xml')))">  
    205                     <xsl:for-each select="saxon:evaluate($xpath)"> 
    206                        <xsl:call-template name="invoke_template_by_name"> 
    207                            <xsl:with-param name="templateName" select="$templateToCall"></xsl:with-param> 
    208                            <xsl:with-param name="width" select="$cur_width"></xsl:with-param> 
    209                        </xsl:call-template> 
    210                   </xsl:for-each> 
    211                 </xsl:for-each> 
    212             </xsl:if>             
    213         </xsl:otherwise> 
    214     </xsl:choose> 
    215 </xsl:template>    
    216      
    217182  <!-- too bad that can only use standard xsl:call-template(name can not be variable)  
    218183         error occurs if use <saxson:call-templates($templateToCall)  /> --> 
    219184 <xsl:template name="invoke_template_by_name"> 
    220      <xsl:param name="templateName"></xsl:param>      
     185     <xsl:param name="templateName"></xsl:param> 
     186     <xsl:param name="name"></xsl:param>  
    221187     <xsl:param name="width"></xsl:param> 
    222188     <xsl:if test="$templateName='top'"> 
     
    238204     </xsl:if> 
    239205 </xsl:template> 
    240      
    241 <xsl:template name="insert_comma"> 
    242         <xsl:choose> 
    243                 <xsl:when test="$first"> 
    244                         <saxon:assign name="first" select="false()"/> 
    245                 </xsl:when> 
    246                 <xsl:otherwise> 
    247                         <xsl:text>,</xsl:text> 
    248                 </xsl:otherwise> 
    249         </xsl:choose> 
    250 </xsl:template> 
    251206</xsl:stylesheet>