[ http://nagoya.apache.org/jira/browse/XALANJ-2004?page=comments#action_56459 ] Mukul Gandhi commented on XALANJ-2004: --------------------------------------
I have tested with the latest Xalan-J version from CVS. The bug has been fixed! Thanks a lot! Regards, Mukul > Seems a Xalan bug > ----------------- > > Key: XALANJ-2004 > URL: http://nagoya.apache.org/jira/browse/XALANJ-2004 > Project: XalanJ2 > Type: Bug > Components: Xalan > Versions: 2.6 > Environment: Windows 2000 Prof, Xalan-J 2.6.0, JDK 1.4(the bundled Xalan > disabled) > Reporter: Mukul Gandhi > > Hello, > I seem to have discovered a Xalan bug(Xalan-J 2.6.0)! I found it while > solving a problem posted at a public newsgroup.. > The problem posted was - > Subject: Grouping by two or any number > -------------------------------------- > I have the following xml > <Parent> > <node>a</node> > <node>s</node> > <node>d</node> > <node>f</node> > <node>g</node> > <node>h</node> > <node>j</node> > <node>k</node> > <node>l</node> > </Parent> > Need to print in following format (into groups of two; or could be any other > group-size) > group 1 - a,s > group 2 - d,f > group 3 - g,h > group 4 - j,k > group 5 - l > To solve this problem, I wrote the following stylesheet - > <?xml version="1.0"?> > <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"> > > <xsl:output method="text" /> > <xsl:param name="group-size" select="3" /> > > <xsl:template match="/Parent"> > <!-- calculate the no of "node" elements, which are left as a fraction; > which are to be displayed in the last group --> > <xsl:variable name="n" select="count(node) - > (floor((count(node) div $group-size)) * $group-size)" > /> > > <xsl:for-each select="node"> > <!-- determine group boundary; this if test stops at the last "node" > element of the group --> > <xsl:if test="(position() mod $group-size) = 0"> > group <xsl:value-of select="floor(position() > div $group-size)" /><xsl:text> - </xsl:text> > <!-- display group members --> > <xsl:for-each select=". | > preceding-sibling::node[position() <= ($group-size > - 1)]"> > <xsl:value-of select="." /><xsl:if > test="(position() mod $group-size) != > 0"><xsl:text>,</xsl:text></xsl:if> > </xsl:for-each> > <xsl:text>
</xsl:text> > </xsl:if> > <!-- this if test processes the last group; whose number of group > members will be less than the group-size --> > <xsl:if test="((position() = last()) and > ((position() mod $group-size) != 0))"> > group <xsl:value-of select="floor(position() > div $group-size) + 1" /><xsl:text> - </xsl:text> > <xsl:for-each select=". | > preceding-sibling::node[position() < $n]"> > <xsl:value-of select="." /><xsl:if > test="position() != > last()"><xsl:text>,</xsl:text></xsl:if> > </xsl:for-each> > <xsl:text>
</xsl:text> > </xsl:if> > </xsl:for-each> > </xsl:template> > > </xsl:stylesheet> > I invoke Xalan like this: > java org.apache.xalan.xslt.Process -in file.xml -xsl > file.xsl -PARAM group-size 2 > The output is fine for -PARAM group-size values of > 1,2,3 & 4. But for -PARAM group-size values of 5 and > above, the ouput is not coming as expected. For e.g., > for -PARAM group-size 5, the output received is - > group 1 - a,s,d,f,g > group 2 - h, > I tested the same XSL with Saxon 8 and MSXSL 4, > and both produce correct result for all the cases(i.e. for any group-size). > Both Saxon and MSXSL produce the following output for > group-size=5 - > group 1 - a,s,d,f,g > group 2 - h,j,k,l > Could it be a Xalan bug? > Regards, > Mukul -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://nagoya.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
