Changeset 7897

Show
Ignore:
Timestamp:
04/01/07 20:54:36 (22 months ago)
Author:
peller
Message:

Run saxon in-process rather than forking hundreds of jvms :) Remove kludge to copy xslts, pass path instead. Refs #2624

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

Legend:

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

    r7860 r7897  
    99 
    1010        <!-- project properties --> 
    11         <!-- FIXME: use location instead of value where appropriate? --> 
    1211        <property name="project" value="dojo"/> 
    13         <property name="root" value="../../.."/> 
    14         <property name="lang" value="en"/> 
     12        <property name="root" location="../../.."/> 
    1513        <property name="dojoLoader" value="default"/> 
    16         <property name="currencies" value="GBP,USD,CAD,AUD,EUR,CHF,HKD,JPY"/>   <!-- FIXME: arbitrary list. Can be altered or eliminated for all currencies --> 
     14        <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 --> 
    1715        <property name="ldml" location="ldml"/> 
    1816        <property name="json" location="${root}/dojo/cldr/nls"/> 
     
    4543                                <include name="js.jar"/> 
    4644                                <include name="ant-apache-bsf.jar"/> 
     45                                <include name="saxon8.jar"/> 
     46                                <include name="resolver.jar"/> 
    4747                        </fileset> 
    4848                </copy> 
     
    9090                        return true; 
    9191                } 
    92                  
     92 
    9393                var delTask = project.createTask("delete"); 
    9494                function deleteResource(f){ 
     
    113113                load.setProperty(uniqueId); 
    114114                load.perform(); 
    115          
     115 
    116116                var contents = String(project.getProperty(uniqueId)); 
    117117                if(contents.charCodeAt(0) == 0xfeff){ contents = contents.substring(1); } // JDK bug workaround 
     
    138138                <macrodef name="processLdml"> 
    139139                        <attribute name="in"/> 
     140                        <attribute name="basedir"/> 
    140141                        <attribute name="destdir"/> 
    141142 
    142143                        <sequential> 
    143144                                <mkdir dir="@{destdir}"/> 
    144                                 <saxon in="@{in}" style="calendar.xsl" destdir="@{destdir}"/> 
    145                                 <saxon in="@{in}" style="number.xsl" destdir="@{destdir}"/> 
    146                                 <saxon in="@{in}" style="currency.xsl" destdir="@{destdir}"/> 
     145                                <transform in="@{in}" style="calendar.xsl" basedir="@{basedir}" destdir="@{destdir}"/> 
     146                                <transform in="@{in}" style="number.xsl" basedir="@{basedir}" destdir="@{destdir}"/> 
     147                                <transform in="@{in}" style="currency.xsl" basedir="@{basedir}" destdir="@{destdir}"/> 
    147148                                <echo level="info" message="Transformed @{in} to @{destDir}" taskName="cldr"/> 
    148149                                <removeEmptyOutput dir="@{destdir}" /> 
    149150                        </sequential> 
    150151                </macrodef> 
    151                 <macrodef name="saxon"> 
    152                         <!-- XSLT ant tasks run for a while, then hang. Perhaps there's a file handle leak? 
    153                                  Kludge: Run as separate JVM processes instead to be safe. --> 
     152                <macrodef name="transform"> 
    154153                        <attribute name="in"/> 
    155154                        <attribute name="style"/> 
     155                        <attribute name="basedir"/> 
    156156                        <attribute name="destdir"/> 
    157157 
    158158                        <sequential> 
    159                                 <java fork="true" dir="@{destdir}" jar="lib/saxon8.jar"> 
    160                                         <!-- Reference the DTD locally to speed things up --> 
    161                                         <!-- resolver and CatalogManager.properties have to be on the bootclasspath, apparently 
    162                                                  in order for JAXP to find them --> 
    163                                         <jvmarg value="-Xbootclasspath/a:${ldml}/../lib/resolver.jar"/> 
    164                                         <jvmarg value="-Xbootclasspath/a:${ldml}"/> 
    165                                         <arg value="-r"/> 
    166                                         <arg value="org.apache.xml.resolver.tools.CatalogResolver"/> 
    167                                         <arg value="-x"/> 
    168                                         <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/> 
    169                                         <arg value="-y"/> 
    170                                         <arg value="org.apache.xml.resolver.tools.ResolvingXMLReader"/> 
    171                                         <arg file="@{in}"/> 
    172                                         <arg file="@{style}"/> 
    173                                         <arg value="currencyList=${currencies}"/> 
    174                                 </java> 
     159                                <xslt includes="@{in}" style="@{style}" destdir="@{destdir}" basedir="@{basedir}" extension=".tmp"> 
     160                                        <factory name="net.sf.saxon.TransformerFactoryImpl" /> 
     161                                        <xmlcatalog> 
     162                                                <catalogpath path="ldml/catalog" /> 
     163                                        </xmlcatalog> 
     164                                        <param name="currencyList" expression="${currencies}" /> 
     165                                </xslt> 
     166                                <delete> 
     167                                        <fileset dir="@{destdir}" includes="*.tmp" /> 
     168                                </delete> 
    175169                        </sequential> 
    176170                </macrodef> 
     
    192186 
    193187                var ldml = project.createTask("processLdml"); 
    194                 ldml.setDynamicAttribute("in", new java.io.File(basedir+"/"+filename)); 
     188                ldml.setDynamicAttribute("in", new java.io.File(filename)); 
    195189                ldml.setDynamicAttribute("destdir", outDir); 
     190                ldml.setDynamicAttribute("basedir", basedir); 
    196191                ldml.perform(); 
    197192        } 
    198193                        ]]> 
    199194                </scriptdef> 
    200  
    201                 <!-- kludge to fix the "Fail to load **.xml" exception which occurs in IBM JDK 1.4.2 
    202                         where saxon uses wrong base with relative URIs. AP: Sun Java 1.5 also? --> 
    203                 <copy todir="${ldml}/core/main"> 
    204                    <fileset dir="."> 
    205                      <include name="**/*.xsl"/> 
    206                    </fileset> 
    207                 </copy> 
    208195 
    209196                <delete dir="${json}" /> 
  • util/trunk/buildscripts/cldr/calendar.xsl

    r7858 r7897  
    494494            <!-- source is an external xml file --> 
    495495            <xsl:if test="string-length($xpath)>0"> 
    496                 <xsl:for-each select="doc(concat($source,'.xml'))">  
     496                <xsl:for-each select="doc(concat('ldml/core/main/',concat($source,'.xml')))">  
    497497                    <xsl:for-each select="saxon:evaluate($xpath)"> 
    498498                       <xsl:call-template name="invoke_template_by_name"> 
  • util/trunk/buildscripts/cldr/currency.xsl

    r7858 r7897  
    125125                <!-- source is an external xml file --> 
    126126                <xsl:if test="string-length($xpath)>0"> 
    127                     <xsl:for-each select="doc(concat($source,'.xml'))">  
     127                        <xsl:for-each select="doc(concat('ldml/core/main/',concat($source,'.xml')))">  
    128128                        <xsl:for-each select="saxon:evaluate($xpath)"> 
    129129                            <xsl:call-template name="invoke_template_by_name"> 
  • util/trunk/buildscripts/cldr/number.xsl

    r7858 r7897  
    202202            <!-- source is an external xml file --> 
    203203            <xsl:if test="string-length($xpath)>0"> 
    204                 <xsl:for-each select="doc(concat($source,'.xml'))">  
     204                <xsl:for-each select="doc(concat('ldml/core/main/',concat($source,'.xml')))">  
    205205                    <xsl:for-each select="saxon:evaluate($xpath)"> 
    206206                       <xsl:call-template name="invoke_template_by_name">