You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/01/15 16:47:11 UTC

DO NOT REPLY [Bug 5864] New: - Recursive is too slow

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5864>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5864

Recursive <xsl:call-template> is too slow

           Summary: Recursive <xsl:call-template> is too slow
           Product: XalanJ2
           Version: 2.1.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Xalan
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: konstantin.romanovsky@atbusiness.com


When I'm trying to process standard recursive template Xalan suffers 
significant persormance problem. It seems it produces too many nested loops 
inside.
The source XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Records>
	<Record ID="1"/>
	<Record ID="1"/>
	<Record ID="1"/>
	<Record ID="1"/>
	<Record ID="5"/>
	<Record ID="5"/>
	<Record ID="5"/>
	<Record ID="5"/>
	<Record ID="42"/>
	<Record ID="42"/>
	<Record ID="42"/>
	<Record ID="42"/>
	<Record ID="133"/>
	<Record ID="133"/>
	<Record ID="133"/>
	<Record ID="133"/>
	<Record ID="139"/>
	<Record ID="139"/>
	<Record ID="139"/>
	<Record ID="139"/>
	<Record ID="146"/>
	<Record ID="146"/>
	<Record ID="146"/>
	<Record ID="146"/>
</Records>

Now imagine, I'm trying to do something like: SELECT DISTINCT Record from that 
file.

XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
	version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	

	<xsl:template match="/">
		<xsl:copy>
			<xsl:apply-templates select="Records"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="Records">
		<xsl:element name="case_info">
			<xsl:call-template name="process-record">
				<xsl:with-param name="nodeset" select="Record"/>
			</xsl:call-template>
		</xsl:element>
	</xsl:template>
	
	<xsl:template name="process-record">
		<xsl:param name="nodeset"/>
		<xsl:variable name="current-count" select="count($nodeset)"/>

		<xsl:element name="CURRENT_COUNT">
			<xsl:value-of select="$current-count"/>			
	
		</xsl:element>		

		<xsl:if test="$current-count != 0">
			<xsl:variable name="current-node" select="$nodeset[1]"/>
			<xsl:variable name="current-id" select="$current-
node/@ID"/>

			<xsl:element name="CURRENT_ID">
				<xsl:value-of select="$current-id"/>
			</xsl:element>		

			<xsl:call-template name="process-record">
				<xsl:with-param name="nodeset" select="$nodeset
[@ID != $current-id]"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

</xsl:stylesheet>

And the command-line bat file:
java -classpath xerces.jar;xalan.jar org.apache.xalan.xslt.Process -IN 
test.xml -XSL test.xsl -OUT test.out -DIAG -TT -TTC

And it seems like Xalan performs each next nested call slower than previous one.
Tested with XalanJ2-1-0 "stable build" and with latest XalanJ2_2_D14.

When I used old XalanJ1 everything was just fine and fast with the same XML, 
XSL and bat file.