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 2001/04/20 21:38:56 UTC
[Bug 1443] New - soccer team score card example has incorrect ouput
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1443
*** shadow/1443 Fri Apr 20 12:38:56 2001
--- shadow/1443.tmp.9640 Fri Apr 20 12:38:56 2001
***************
*** 0 ****
--- 1,253 ----
+ +============================================================================+
+ | soccer team score card example has incorrect ouput |
+ +----------------------------------------------------------------------------+
+ | Bug #: 1443 Product: XalanJ2 |
+ | Status: NEW Version: 2.0.0 |
+ | Resolution: Platform: Sun |
+ | Severity: Normal OS/Version: Solaris |
+ | Priority: Medium Component: org.apache.xalan.xsltc |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xalan-dev@xml.apache.org |
+ | Reported By: tamiro@east.sun.com |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ [taken from SunMicrosystem's bug 4423441]
+ xsltc does not produce the correct output for the example on using the count()
+ and sum() functions from page 523 of M Kay's XSLT Programmer's reference. The
+ example also involves variables, and complex predicates.
+ Saxon, XT, and Xalan give the correct results, while XSLTC
+ does not add up the wins, losses, draws, etc correctly.
+
+ Correct output is
+
+ <html>
+ <body>
+ <h1>Results of Group A</h1>
+ <table cellpadding="5">
+ <tr>
+ <td>Team</td><td>Played</td><td>Won</td><td>Drawn</td><td>Lost</td><td>For</td><td>Against</td>
+ </tr>
+ <tr>
+ <td>Brazil</td><td>3</td><td>2</td><td>0</td><td>1</td><td>6</td><td>3</td>
+ </tr>
+ <tr>
+ <td>Scotland</td><td>3</td><td>0</td><td>1</td><td>2</td><td>2</td><td>6</td>
+ </tr>
+ <tr>
+ <td>Morocco</td><td>3</td><td>1</td><td>1</td><td>1</td><td>5</td><td>5</td>
+ </tr>
+ <tr>
+ <td>Norway</td><td>3</td><td>1</td><td>2</td><td>0</td><td>5</td><td>4</td>
+ </tr>
+ </table>
+ </body>
+ </html
+
+ XSLT outputs
+
+ <html><body><h1>Results of Group A</h1>
+ <table cellpadding="5"><tr><td>Team</td>
+ <td>Played</td>
+ <td>Won</td>
+ <td>Drawn</td>
+ <td>Lost</td>
+ <td>For</td>
+ <td>Against</td>
+ </tr>
+ <tr><td>Brazil</td>
+ <td>1</td>
+ <td>2</td>
+ <td>0</td>
+ <td>1</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Scotland</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Morocco</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Norway</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Scotland</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Norway</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Brazil</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Morocco</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Brazil</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Norway</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Scotland</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ <tr><td>Morocco</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ <td>0</td>
+ </tr>
+ </table>
+ </body>
+ </html>
+
+ There are two problems: the 0 values are wrong, and
+ the country rows are repeated.
+
+ XML File
+ ===================================================================
+ <results group="A">
+ <match>
+ <date>10-Jun-98</date>
+ <team score="2">Brazil</team>
+ <team score="1">Scotland</team>
+ </match>
+ <match>
+ <date>10-Jun-98</date>
+ <team score="2">Morocco</team>
+ <team score="2">Norway</team>
+ </match>
+ <match>
+ <date>16-Jun-98</date>
+ <team score="1">Scotland</team>
+ <team score="1">Norway</team>
+ </match>
+ <match>
+ <date>16-Jun-98</date>
+ <team score="3">Brazil</team>
+ <team score="0">Morocco</team>
+ </match>
+ <match>
+ <date>23-Jun-98</date>
+ <team score="1">Brazil</team>
+ <team score="2">Norway</team>
+ </match>
+ <match>
+ <date>23-Jun-98</date>
+ <team score="0">Scotland</team>
+ <team score="3">Morocco</team>
+ </match>
+ </results>
+
+ XSL File
+ ======================================================================
+ <xsl:transform
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0"
+ >
+
+ <xsl:variable name="teams" select="//team[not(.=preceding::team)]"/>
+ <xsl:variable name="matches" select="//match"/>
+
+ <xsl:template match="results">
+ <html><body>
+ <h1>Results of Group <xsl:value-of select="@group"/></h1>
+
+ <table cellpadding="5">
+ <tr>
+ <td>Team</td>
+ <td>Played</td>
+ <td>Won</td>
+ <td>Drawn</td>
+ <td>Lost</td>
+ <td>For</td>
+ <td>Against</td>
+ </tr>
+ <xsl:for-each select="$teams">
+ <xsl:variable name="this" select="."/>
+ <xsl:variable name="played" select="count($matches[team=$this])"/>
+ <xsl:variable name="won"
+ select="count($matches[team[.=$this]/@score >
+ team[.!=$this]/@score])"/>
+ <xsl:variable name="lost"
+ select="count($matches[team[.=$this]/@score <
+ team[.!=$this]/@score])"/>
+ <xsl:variable name="drawn"
+ select="count($matches[team[.=$this]/@score =
+ team[.!=$this]/@score])"/>
+ <xsl:variable name="for"
+ select="sum($matches/team[.=current()]/@score)"/>
+ <xsl:variable name="against"
+ select="sum($matches[team=current()]/team/@score) - $for"/>
+
+ <tr>
+ <td><xsl:value-of select="."/></td>
+ <td><xsl:value-of select="$played"/></td>
+ <td><xsl:value-of select="$won"/></td>
+ <td><xsl:value-of select="$drawn"/></td>
+ <td><xsl:value-of select="$lost"/></td>
+ <td><xsl:value-of select="$for"/></td>
+ <td><xsl:value-of select="$against"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </body></html>
+ </xsl:template>
+
+ </xsl:transform>