[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Performance Problem Transforming Large Document

Subject: Performance Problem Transforming Large Document
From: "Schwartz, Rechell R, ALABS" <rrschwartz@xxxxxxx>
Date: Wed, 18 Jun 2003 12:40:41 -0500
transforming large xml files
All,

I have an application where I transform an XML string into an XML document (which contains HTML) , and then transform the document to an HTML file containing special styling elements (alternate color rows), which I send directly to the browser.

The performance has been fine up until recently, when I encountered a very large XML file. Following is the code used for the transformations, and where the performance bottleneck occurred. Below the code, I have included the text from format.xsl, the stylesheet used in the bottlenecked transaction. Any suggestions on how to improve performance would be greatly appreciated. For a large file, it seems to be taking several minutes for the second transformation to take place.

Thanks in advance,
Rechell Schwartz

	 String flashText = sb.toString();
            if (flashText == null) flashText = "";
            String noflashText = "*** No flashes found
            TransformerFactory tFactory = TransformerFactory.newInstance();
	String xsl = "/stylesheets/data.xsl";
	Transformer transformer = tFactory.newTransformer(new StreamSource(getClass().getResourceAsStream(xsl)));
	transformer.setParameter("flash", flashText);
	transformer.setParameter("noflash", noflashText);
	String site_name = "".equals(hand.site_name) ? "N/A" : hand.site_name;
	transformer.setParameter("sitename", site_name);
	DOMResult domResult = new DOMResult();
	transformer.transform(new StreamSource(new StringReader(hand.detailresult)), domResult);
	Document document =(Document)domResult.getNode();
	xsl = "/stylesheets/format.xsl";
	transformer = tFactory.newTransformer(new StreamSource(getClass().getResourceAsStream(xsl)));

/** There is a huge bottleneck right here when the original XML file is very large

	transformer.transform(new DOMSource(document), new StreamResult(out));

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Text of format.xsl

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                   version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:template match="node()|@*"> <!--identity transform-->
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
</xsl:template>

<xsl:template match="table/tr[td[not(a) and not(@class)]]">
        <xsl:copy>
     <xsl:choose>
     <xsl:when test="count( preceding-sibling::tr[td[not(a)  and 
not(@class)]] ) mod 2 = 1">
     <xsl:for-each select="td[1]">
      <td class="evenMedium" width="35%">
       <xsl:apply-templates select="node()|@*"/>
       </td>
      </xsl:for-each>
      <xsl:for-each select="td[2]">
      <td class="evenMedium" width="65%">
       <xsl:apply-templates select="node()|@*"/>
       </td>
      </xsl:for-each>
     </xsl:when>
     <xsl:otherwise>
     <xsl:for-each select="td[1]">
       <td class="oddMedium" width="35%">
       <xsl:apply-templates select="node()|@*"/>
       </td>
      </xsl:for-each>
       <xsl:for-each select="td[2]">
       <td class="oddMedium" width="65%">
       <xsl:apply-templates select="node()|@*"/>
       </td>
      </xsl:for-each>
     </xsl:otherwise>
     </xsl:choose>
       </xsl:copy>
</xsl:template>


</xsl:stylesheet>

	

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.