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 2004/01/09 14:46:11 UTC

DO NOT REPLY [Bug 26019] New: - infinit loop processing appearing with Xalan J 2.5.2

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=26019>.
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=26019

infinit loop processing appearing with Xalan J 2.5.2

           Summary: infinit loop processing appearing with Xalan J 2.5.2
           Product: XalanJ2
           Version: 2.5Dx
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: javax.xml
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: benoit.lefevre@reuters.com


I asked to Henry Zongaro to test this bug.

  He told it was effectively one and asked me to 
  post it here.

  I build a test case composed of three files to 
  present it.

  One input file (testCaseInput.xml) 
  One output file (testCaseOutput.xml)
  One stylesheet (testCase.xsl)

  You'll find these files at the end of this document.

  Here is the probleme :
  The following transformation is working fine with 
  Xalan J 2 embedded in the JDK 1.4.1. but with Xalan 
  J 2.5.2, it is looping infinitly.

  So as you can guess, it the testCaseOutput.xml file
  is the one i get with the JDK Xalan J 2 processor.

  For further explainations, please refere to the 
  comments i included in the XSL file.

Regards.

Benoit Lefevre.


----- testCaseInput.xml -----

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="./testCase.xsl" type="Text/xsl"?>
<recordSet>
	<record name="User" Value="1"/>
	<record name="User" Value="2"/>
	<record name="Date" Value="3"/>
	<record name="Date" Value="4"/>
	<record name="Action" Value="5"/>
	<record name="Action" Value="6"/>
</recordSet>

----- testCaseOutput.xml -----

<?xml version="1.0" encoding="UTF-8"?>
<recordSet>
	<group name="User">
		<record Value="1"/>
		<record Value="2"/>
	</group>
	<group name="Date">
		<record Value="3"/>
		<record Value="4"/>
	</group>
	<group name="Action">
		<record Value="5"/>
		<record Value="6"/>
	</group>
</recordSet>

----- testCase.xsl -----

<?xml version="1.0" encoding="UTF-8"?>

<!--
	The following transformation is working fine with XalanJ2 embended into 
	JDK 1.4, but with XalanJ2 V2.5.2, it's looping infinitly.
	
	Can you tell me why ?

	To sum up, it is supposed to act like a group by in SQL.

	To have a better idea of what i mean, i joined to this stylesheet an 
input XML 
	file (testCaseInput.xml) AND the resulting output file 
(testCaseOutput.xml) 
	that i obtained with XalanJ2 from JDK 1.4.
	
	For further explainations about this transformation please, 
	read the following comments
	
	Thank you.
	
	eMail : benoit.lefevre@reuters.com
-->


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
						
	xmlns:xalan="http://xml.apache.org/xalan"
							exclude-result-
prefixes="xalan">

	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" 
media-type="xml"/>

	<!-- first template -->
	<xsl:template match="/">
		<xsl:copy>
			<xsl:apply-templates select="@* | * | comment() | text
()"/>
		</xsl:copy>
	</xsl:template>

	<!-- identity like template -->
	<xsl:template match="@* | * | comment() | text()">
		<xsl:copy>
			<xsl:apply-templates select="@* | * | comment() | text
()"/>
		</xsl:copy>
	</xsl:template>
	
	<!-- We start the group by process here -->
	<xsl:template match="recordSet" priority="1">
		<xsl:copy>
		<!--	<xsl:copy-of select="xalan:checkEnvironment()"/> -->

			<!-- the process start with the first element of 
the "record" tag list -->
			<xsl:apply-templates select="record[1]" mode="groupBy"/>
		</xsl:copy>
	</xsl:template>


	<!-- When a record tag is matched, we try to group tags having the same 
name than 
		this one all together in a new tag. Then we repeate the process 
on remaining nodes-->
	<xsl:template match="record" priority="1" mode="groupBy">
	
		<!-- this parameter store names of tags that have allready been 
handled in previous calls -->
		<xsl:param name="prevNames" select="@name"/>
		
		<!-- let's remember the current tag name to simplify next XPath 
formulations -->
		<xsl:variable name="currentName" select="@name"/>

		<!-- we create a "group" tag to performe the grouping process --
> 
		<xsl:element name="group">
			
			<!-- This "group" tag have the same name than the nodes 
that are going to be stored inside -->
			<xsl:attribute name="name"><xsl:value-of 
select="@name"/></xsl:attribute>
			
			<!-- first we copy the current "record" tag by calling 
the second "record" template (getRideOf mode) -->
			<xsl:apply-templates select="." mode="getRideOf"/>
			
			<!-- then, we copy the sibblings of this tag who look 
like the current one (getRideOf mode again) -->
			<xsl:apply-templates select="following-sibling::*
[@name=$currentName]" mode="getRideOf"/>
		</xsl:element>
		
		<!-- Finally we call again the "record" template (groupBy mode) 
by 
			selecting the first sibbling of this node that haven't 
been processed yet -->
		<xsl:apply-templates select="../record[@name!=$currentName][not
(@name=$prevNames)][1]" mode="groupBy">
			<xsl:with-param name="prevNames" select="preceding-
sibling::*/@name|./@name"/>
		</xsl:apply-templates>
		
		<!--~~~~~~~~~~~~~~~~~~~~~~~~~~-->
		<!-- i guess it's one of the tow preceding select statements 
which cause the bug, but i can't figure out why -->		
		<!--~~~~~~~~~~~~~~~~~~~~~~~~~~-->
	</xsl:template>


	<!-- this "record" template is used to copy completly a "record" tag 
but it's @name -->
	<xsl:template match="record" priority="1" mode="getRideOf">
		<xsl:copy>
			<xsl:apply-templates select="@*[not(name(.)='name')] | 
* | comment() | text()"/>
		</xsl:copy>
	</xsl:template>


</xsl:stylesheet>