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/03/15 17:18:27 UTC
DO NOT REPLY [Bug 7152] New: -
infinite loop is generated in xsl:for-each
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=7152>.
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=7152
infinite loop is generated in xsl:for-each
Summary: infinite loop is generated in xsl:for-each
Product: XalanJ2
Version: 2.3
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Critical
Priority: Other
Component: org.apache.xalan.transformer
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: wu@gst.com
we used to use xalan 2.1.0 to transform, it's ok. but the problem happens in
xalan 2.3.1 and jdk1.4 is having same problem. The result is like this:
public String toString()
{
String result = "{";
result += "name=";
result += name;
result += "name=";
result += name;
result += "name=";
result += name;
result += "name=";
result += name;
result += "name=";
result += name;
result += "name=";
result += name;
result += "name=";
result += name;
we check the xslt and find it's xsl:for-each that cause this problem. Here are
the xml and xslt
<DataType>
<Class name="AttributeDefinition">
<Description>
<Paragraph text="This data type specifies the
minimal schema entries for an attribute."/>
</Description>
<Attribute name="name" type="String"
multiplicity="one"/>
<Attribute name="definition" type="String"
multiplicity="one"/>
<Attribute name="representationCategory" type="String"
multiplicity="one"/>
</Class>
</DataType>
================================================================================
public String toString()
{
String result = "{";
<xsl:for-each select="./Attribute">
<xsl:variable name="variableTypeNodes" select="id(./@type)"/>
<xsl:variable name="theAttribute" select="."></xsl:variable>
<xsl:for-each select="$variableTypeNodes">
<xsl:variable name="attributeName"/>
<xsl:text>result += "</xsl:text>
<xsl:choose>
<xsl:when test="(count($variableTypeNodes)>1)">
<xsl:variable name="attrEnumName"
select="./@name"/>
<xsl:variable name="attributeName"
select="concat($theAttribute/@name,'_',$attrEnumName)"/>
<xsl:value-of
select="$attributeName"/><xsl:text>=";</xsl:text>
<xsl:choose>
<xsl:when
test="($theAttribute/@multiplicity='one_or_more') or
($theAttribute/@multiplicity='zero_or_more')">
if(<xsl:value-of select="$attributeName"/> != null){
result += "(";
for(int i=0; i <<xsl:value-of select="$attributeName"/>.length; i++){
result += <xsl:value-of select="$attributeName"/>[i];
if(i < <xsl:value-of select="$attributeName"/>.length - 1){
result += ",";
}
}
result += ")";
}
else result += "null";
</xsl:when>
<xsl:otherwise>
result += <xsl:value-of select="$attributeName"/>;
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="attributeName"
select="$theAttribute/@name"/>
<xsl:value-of
select="$attributeName"/><xsl:text>=";</xsl:text>
<xsl:choose>
<xsl:when
test="($theAttribute/@multiplicity='one_or_more') or
($theAttribute/@multiplicity='zero_or_more')">
if(<xsl:value-of select="$attributeName"/> != null){
result += "(";
for(int i=0; i <<xsl:value-of select="$attributeName"/>.length; i++){
result += <xsl:value-of select="$attributeName"/>[i];
if(i < <xsl:value-of select="$attributeName"/>.length - 1){
result += ",";
}
}
result += ")";
}
else result += "null";
</xsl:when>
<xsl:otherwise>
result += <xsl:value-of select="$attributeName"/>
<xsl:text>;
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<!-- <xsl:text>=";</xsl:text> -->
<!-- <xsl:choose>
<xsl:when
test="($theAttribute/@multiplicity='one_or_more') or
(theAttribute/@multiplicity='zero_or_more')">
if(<xsl:value-of select="$attributeName"/> != null){
result += "(";
for(int i=0; i <<xsl:value-of select="$attributeName"/>.length; i++){
result += <xsl:value-of select="$attributeName"/>[i];
if(i < <xsl:value-of select="$attributeName"/>.length - 1){
result += ",";
}
}
result += ")";
}
else result += "null";
</xsl:when>
<xsl:otherwise>
result += <xsl:value-of select="$attributeName"/>;
</xsl:otherwise>
</xsl:choose> -->
<xsl:if test="not(position() = last())"><xsl:text/><xsl:text/>
result += ", ";
</xsl:if>
</xsl:for-each>
<xsl:if test="not(position() = last())"><xsl:text>result += ", ";
</xsl:text></xsl:if>
</xsl:for-each>
result += "}";
return result;
}
}