Subject: [xsl] How do i optimize my stylesheet for speed? From: wahmed001@xxxxxxxxxxxx (Wajihuddin Ahmed) Date: Thu, 14 Jun 2001 19:19:38 -0400 |
Folks, I have written a stylesheet that takes a catalog from an application in xml format and converts to a csf (character seperated file) text file. On a single CPU ultarsparc 248MHz, 384MB RAM, with 128MB of heap size it is taking about 10 min for a 5MB input file. However on a 4CPU (400MHz) box it is just taking a megre 42 sec. What can i do to make it faster on the slow machine? Also in the output, on the 1st row i want to get the name of the attributes (not values). So that i have a column heading for the whole file. How can i do that? I tried using counters and some logic with when-otherwise but failed. Thanks -Wajih My input is something like this. <vortex-data-load> <category1> <category1a> <category1N> <itemA> <Attribute name=sku value=1234 /> . . </itemA> <item B> . . <item N> <category1..n> <category1a> </category1> <category2> <ItemAA> . . </ItemAA> </category2> <categoryN> . . </categoryN> </vortex-data-load> The stylesheet ----------------- <?xml version="1.0"?> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output method="text"/> <xsl:variable name="cat" select="vortex-data-load//*[@vortex-type='category']" /> <xsl:template match="vortex-data-load"> <xsl:for-each select="$cat"> <xsl:apply-templates select="Item" /> </xsl:for-each> </xsl:template> <xsl:template match="Item"> <xsl:for-each select="Attribute"> <xsl:value-of select="@value" /> <xsl:if test="position()!=last()"> <xsl:text>|</xsl:text> </xsl:if> </xsl:for-each> <xsl:call-template name="parents" /> <xsl:text>
</xsl:text> </xsl:template> <xsl:template name="parents"> <xsl:for-each select="ancestor-or-self::*"> <xsl:value-of select="@name" /> <xsl:if test="position()!=last()"> <xsl:text>|</xsl:text> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> Few lines of actual output -------------------------- 8.0|BOOKCASE,36X48,3SHLF,MAH|132328|48.0|/catalogs/horizon/images/132328.gif|Bookcase3-Shelf|132328|3|407.0000|1003|132328|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01| 8.0|BOOKCASE,36X36,2SHLF,MAH|132331a|36.0|/catalogs/horizon/images/132331.gif|Bookcase2-Shelf|132331a|2|322.0000|2000|132331a|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a| 8.0|BOOKCASE,36X30,1SHLF,MAH|132271a|30.0|/catalogs/horizon/images/132271.gif|Bookcase1-Shelf|132271a|1|274.0000|2000|132271a|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a| 8.0|BOOKCASE,36X72,5SHLF,MAH|132296a|72.0|/catalogs/horizon/images/132296.gif|Bookcase5-Shelf|132296a|5|567.0000|2000|132296a|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a| 8.0|BOOKCASE,36X60,4SHLF,MAH|132325a|60.0|/catalogs/horizon/images/132325.gif|Bookcase4-Shelf|132325a|4|497.0000|2002|132325a|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a| 8.0|BOOKCASE,36X48,3SHLF,MAH|132328a|48.0|/catalogs/horizon/images/132328.gif|Bookcase3-Shelf|132328a|3|407.0000|2003|132328a|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a| 8.0|BOOKCASE,36X36,2SHLF,MAH|132331b|36.0|/catalogs/horizon/images/132331.gif|Bookcase2-Shelf|132331b|2|322.0000|3004|132331b|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a|BOOK01b| 8.0|BOOKCASE,36X30,1SHLF,MAH|132271b|30.0|/catalogs/horizon/images/132271.gif|Bookcase1-Shelf|132271b|1|274.0000|3000|132271b|5b6abf:de3f060a01:-7ff9|EA|HALE MFG CO|36.0|Office Furniture|BOOK01|BOOK01a|BOOK01b| __________________________________________________________________ Get your own FREE, personal Netscape Webmail account today at http://webmail.netscape.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to check for absence , Rene de Vries | Thread | RE: [xsl] How do i optimize my styl, Michael Kay |
RE: [xsl] Copy DocType, bryan . s . schnabel | Date | [no subject], Peter Flynn |
Month |