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/19 23:16:50 UTC
[Bug 1412] New - variable fails to capture context node
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1412
*** shadow/1412 Thu Apr 19 14:16:50 2001
--- shadow/1412.tmp.3165 Thu Apr 19 14:16:50 2001
***************
*** 0 ****
--- 1,127 ----
+ +============================================================================+
+ | variable fails to capture context node |
+ +----------------------------------------------------------------------------+
+ | Bug #: 1412 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 |
+ An important use of variables is in capturing the context
+ node especially with for-each instructions, which change
+ the current node. The following test is taken from page 314 in
+ Michael Kay's XSLT Programmer's Reference manual.
+
+ Saxon, XT, and Xalan produced the correct result, whereas
+ XSLT is missing the <p> elements that should get output
+ by the inside for-each loop.
+
+ Actual Results
+ --------------
+ <html>
+ <body>
+ <center>
+ <h1>Programme</h1>
+ <h2>Wolfgang Amadeus Mozart (1756-1791)</h2>
+ <h2>Guiseppe Verdi (1813-1901)</h2>
+ <h2>Giacomo Puccini (1858-1924)</h2>
+ </center>
+ </body>
+ </html>
+
+ Expected Results
+ ----------------
+ <html>
+ <body>
+ <center>
+ <h1>Programme</h1>
+ <h2>Wolfgang Amadeus Mozart (1756-1791)</h2>
+ <p>The Magic Flute</p>
+ <p>Don Giovanni</p>
+ <h2>Guiseppe Verdi (1813-1901)</h2>
+ <p>Ernani</p>
+ <p>Rigoletto</p>
+ <h2>Giacomo Puccini (1858-1924)</h2>
+ <p>Tosca</p>
+ </center>
+ </body>
+ </html>
+
+ XSL file
+ --------
+ <?xml version="1.0" ?>
+ <xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+ <xsl:output method="html" indent="yes" />
+ <xsl:template match="/">
+ <html>
+ <body>
+ <center>
+ <h1>Programme</h1>
+ <xsl:for-each select="/programme/composer">
+ <h2><xsl:value-of select="concat(fullname, ' (', born, '-', died,
+ ')')"/></h2>
+ <xsl:variable name="c" select="."/>
+ <xsl:for-each select="/programme/opera[composer=$c/@name]">
+ <p><xsl:value-of select="title"/></p>
+ </xsl:for-each>
+ </xsl:for-each>
+ </center>
+ </body>
+ </html>
+ </xsl:template>
+ </xsl:stylesheet>
+
+ XML File
+ --------
+ <?xml version="1.0"?>
+ <programme>
+ <opera>
+ <title>The Magic Flute</title>
+ <composer>Mozart</composer>
+ <date>1791</date>
+ </opera>
+ <opera>
+ <title>Don Giovanni</title>
+ <composer>Mozart</composer>
+ <date>1787</date>
+ </opera>
+ <opera>
+ <title>Ernani</title>
+ <composer>Verdi</composer>
+ <date>1843</date>
+ </opera>
+ <opera>
+ <title>Rigoletto</title>
+ <composer>Verdi</composer>
+ <date>1850</date>
+ </opera>
+ <opera>
+ <title>Tosca</title>
+ <composer>Puccini</composer>
+ <date>1897</date>
+ </opera>
+ <composer name="Mozart">
+ <fullname>Wolfgang Amadeus Mozart</fullname>
+ <born>1756</born>
+ <died>1791</died>
+ </composer>
+ <composer name="Verdi">
+ <fullname>Guiseppe Verdi</fullname>
+ <born>1813</born>
+ <died>1901</died>
+ </composer>
+ <composer name="Puccini">
+ <fullname>Giacomo Puccini</fullname>
+ <born>1858</born>
+ <died>1924</died>
+ </composer>
+ </programme>