Subject: [xsl] follow up re: key execution speed From: Mike Lamb <m@xxxxxxxxxxxxxxxxxxxxx> Date: Fri, 10 Aug 2001 10:45:08 -0400 |
I wrote in last week and received much good advice on using keys to perform lookups during XSL execution. I was advised, properly I am sure, that keys are damn fast and the best way to do nearly anything. However my problem is a little unusual, and is resulting in unsatisfactory performance. The trick is this: while I have been advised that keys are speed for any lookup that will be performed more than once in a transform, my situation is a little more complicated. I only do this lookup once per transform, but I perform this transform many times (thousands!) on different source documents. I was hoping to get the speed benefit of the key across these multiple transformations. My XSL templates make use of two data files, Zips.xml, which maps zip codes to dealer codes, and Dealers.xml, which contains information about each dealer. The idea is to use a key (ziptorc) over the (very large - 400K) Zips file (looks like <ZIP zip='10001' rc='2'/>) to perform the zip-to-dealer mapping, then to use another key over the dealer file (rctodealer) to perform a generic templating of the dealer informaiton. My templates are as follows: <xsl:key name="ziptorc" match="ZIP" use="@zip"/> <xsl:key name="rctodealer" match="DEALER" use="@rc"/> <xsl:template name="TARGETBYZIP"> <!-- target by ZIP --> <xsl:variable name="ZIP"> <xsl:value-of select="ZIP/@val"/> </xsl:variable> <xsl:variable name="RC"> <xsl:for-each select="document('Zips.xml')"> <xsl:value-of select="key('ziptorc', $ZIP)/@rc"/> </xsl:for-each> </xsl:variable> <xsl:for-each select="document('Dealers.xml')"> <xsl:apply-templates select="key('rctodealer', $RC)"/> </xsl:for-each> </xsl:template> <xsl:template match="DEALER"> <!-- generic template for displaying dealer information here --> </xsl:template> I am using Xalan, creating and persisting a Templates object. I am then creating a Transformer object to perform each transform. Performance is very slow; seems to me that it is reloading the data files and recreating the keys every time it performs the transform. Is there some set of changes, to the XSL or to the Java, that will enable me to get the blazing performance I require? Thanks very much for your help. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] putting spaces into docum, Crowers, Steve | Thread | Re: [xsl] follow up re: key executi, Trevor Nash |
RE: [xsl] putting spaces into docum, Crowers, Steve | Date | RE: [xsl] Capitalizing content of a, Mark Nahabedian |
Month |