Your stack overflow seems to have occurred while doing a sort, which is
rather surprising, as the stack depth for a QuickSort should only
increase with the log of the number of nodes to be sorted.
Try a different XSLT processor. XSLTC is fast but isn't the most
reliable.
Other things you could try:
(a) put the xsl:if test
<xsl:if test="generate-id(.)=
generate-id( $currencies[ @CURRENCY =
current()/@CURRENCY ] )">
into a predicate in the select expression of the xsl:for-each
(b) replace the test in this xsl:if with a key. As written, your code is
likely to have O(n^2) performance.
Michael Kay
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Lee, Insoo
Sent: 18 May 2003 18:28
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] stackOverflowError while doing generte-id and sum
We are doing the grouping in order to establish the unique
values for currency and do grand total summation for
following like xml..
<REPORT>
<ENTITY NUMBER="1">
<FUND_GROUP CURRENCY="GBP">
<ROW>
<SOME_VALUE>100</SOME_VALUE>
</ROW>
<ROW>
<SOME_VALUE>200</SOME_VALUE>
</ROW>
<ROW>
<SOME_VALUE>300</SOME_VALUE>
</ROW>
</FUND_GROUP>
<FUND_GROUP CURRENCY="USD">
<ROW>
<SOME_VALUE>100</SOME_VALUE>
</ROW>
<ROW>
<SOME_VALUE>200</SOME_VALUE>
</ROW>
<ROW>
<SOME_VALUE>300</SOME_VALUE>
</ROW>
</FUND_GROUP>
</ENTITY>
<ENTITY NUMBER="2">
<FUND_GROUP CURRENCY="GBP">
<ROW>
<SOME_VALUE>100</SOME_VALUE>
</ROW>
<ROW>
<SOME_VALUE>200</SOME_VALUE>
</ROW>
</FUND_GROUP>
<FUND_GROUP CURRENCY="USD">
<ROW>
<SOME_VALUE>200</SOME_VALUE>
</ROW>
<ROW>
<SOME_VALUE>300</SOME_VALUE>
</ROW>
</FUND_GROUP>
</ENTITY>
</REPORT>
and this xsl works well..
<xsl:for-each select="$currencies">
<xsl:if test="generate-id(.)=
generate-id( $currencies[ @CURRENCY =
current()/@CURRENCY ] )">
<tr>
<td align="left" width="23%"><b>Grand
Total (<xsl:value-of select="@CURRENCY"/>):</b></td>
<td align="right"
width="14%"><xsl:text> </xsl:text></td>
<td align="right"
width="7%"><xsl:text> </xsl:text></td>
<td align="right"
width="14%"><b><u><xsl:value-of select="format-number(sum(
$currencies[(_at_)CURRENCY=current()/@CURRENCY]/FUND_ROW/OPENING_VA
LUE ), '#,###,###,##0.00')"/></u></b></td>
<td align="right"
width="14%"><xsl:text> </xsl:text></td>
<td align="right"
width="14%"><b><u><xsl:value-of select="format-number(sum(
$currencies[(_at_)CURRENCY=current()/@CURRENCY]/FUND_ROW/CURRENT_VALUE),
'#,###,###,##0.00')"/></u></b></td>
<td align="right"
width="14%"><b><u><xsl:value-of select="format-number(sum(
$currencies[(_at_)CURRENCY=current()/@CURRENCY]/FUND_ROW/MTD_DIVIDE
ND_NUMBER),
'#,###,###,##0.00')"/></u></b></td>
</tr>
</xsl:if>
</xsl:for-each>
except once we go over 4500 records or so, we get
stackOverflowError.... what to do?? help!! it generates the
report without grand total.. or sometimes, it crashes tomcat
as well...
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoi
nt.java:534)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.jav
a:530)
at java.lang.Thread.run(Thread.java:479)
----- Root Cause -----
java.lang.StackOverflowError
at
org.apache.xalan.xsltc.util.IntegerArray.quicksort(IntegerArra
y.java:198)
at
org.apache.xalan.xsltc.util.IntegerArray.quicksort(IntegerArra
y.java:198)
at
org.apache.xalan.xsltc.util.IntegerArray.quicksort(IntegerArra
y.java:198)
at
org.apache.xalan.xsltc.util.IntegerArray.quicksort(IntegerArra
y.java:198)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list