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/07/06 01:58:52 UTC
[Bug 2468] New: - AbsoluteIterator.setStartNode(int) not sufficient to initialize a NodeIterator.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2468
*** shadow/2468 Thu Jul 5 16:58:52 2001
--- shadow/2468.tmp.8777 Thu Jul 5 16:58:52 2001
***************
*** 0 ****
--- 1,121 ----
+ +============================================================================+
+ | AbsoluteIterator.setStartNode(int) not sufficient to initialize a NodeIter |
+ +----------------------------------------------------------------------------+
+ | Bug #: 2468 Product: XalanJ2 |
+ | Status: NEW Version: CurrentCVS |
+ | Resolution: Platform: PC |
+ | Severity: Major OS/Version: Windows NT/2K |
+ | Priority: Other Component: org.apache.xalan.xsltc |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xalan-dev@xml.apache.org |
+ | Reported By: johnh@schemasoft.com |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ [Investigation of this bug was accomplished by decompiling the translet using
+ jode-1.1, applying appropriate source-level fixups and finally recompilation
+ and execution of the translet from the new source. This description references
+ annotated lines of code in a snippet of the translet's java source (see
+ attached for complete source).]
+
+ In most cases of compiler generated stylesheets, AbsoluteIterator.setStartNode
+ (int) is followed by a call to cloneIterator() prior to use by the runtime.
+ This bug describes a case when an iterator for an xpath is passed as an
+ argument to a template function and then used, without any intervening call to
+ cloneIterator(). It has been discovered that when a call to cloneIterator() was
+ made directly after the construction of AbsoluteIterator, the stylesheet worked
+ as expected.
+
+ When the enclosed changes are made to mk031.xsl and the translet is compiled,
+ the xpath that is specified as a calling parameter is initialized improperly -
+ resulting in no output. Examining the decompiled translet leads to a <line-of-
+ suspicion> that may be in error (the nodeiterator initialization). See attached
+ source, or code snippet below.
+
+ The translet can be made to work by changing the <line-of-suspicion> as follows
+ (with subsequent recompilation):
+ - ).setStartNode( i ) // *** <line-of-suspicion> ***
+ + ).setStartNode( i ).cloneIterator() // *** <line-of-suspicion> ***
+
+ What is curious about this bug is that it seems related to the presence of an
+ enclosing for-each. This led me down the original train of thought that perhaps
+ the <line-of-suspicion> was being initialized using the state variable i from
+ the wrong scope (i is reassigned by <line-of-curiosity>) and that the following
+ would make things work:
+ - ).setStartNode( i ) // *** <line-of-suspicion> ***
+ + ).setStartNode( i_5_ ) // *** <line-of-suspicion> ***
+
+ Since i_5_ is a saved copy of i from the scope before <line-of-curiosity>. Alas
+ no.
+
+ No tests that cover this case were found in my search of the test suite.
+ mk031.xsl comes close in that it is the only test that specifies an xpath in
+ the "select" of a template parameter. To reproduce the bug, mk031.xsl can be
+ modified as follows:
+
+ XSL diffs
+ ---------
+
+ --- mk031.xsl 2001/06/20 18:54:41 1.1
+ +++ mk031.xsl 2001/07/05 23:11:49
+ @@ -19,9 +19,11 @@
+
+ <xsl:template match="/">
+ <xsl:variable name="list">
+ + <xsl:for-each select="/programme/composer/fullname">
+ <xsl:call-template name="make-list">
+ <xsl:with-param name="names"
+ select="/programme/composer/fullname"/>
+ </xsl:call-template>
+ + </xsl:for-each>
+ </xsl:variable>
+ This week's composers are:
+ <xsl:value-of select="translate($list, ',', ';')"/>
+
+ JAVA (snippet of decompiled translet, reformatted and annotated)
+ ----------------------------------------------------------------
+
+ ...
+ int i_5_ = i;
+ NodeIterator nodeiterator_6_ = nodeiterator;
+ nodeiterator =
+ new AbsoluteIterator(
+ new StepIterator(
+ new StepIterator(
+ domadapter.getTypedAxisIterator(3, 7),
+ domadapter.getTypedAxisIterator(3, 8)
+ ),
+ domadapter.getTypedAxisIterator(3, 9)
+ )
+ ).setStartNode(i);
+ while ((i = nodeiterator.next()) != 0) { // *** <line-of-curiosity> ***
+ this.pushParamFrame();
+ this.addParameter(
+ "names",
+ new AbsoluteIterator(
+ new StepIterator(
+ new StepIterator(
+ domadapter.getTypedAxisIterator(3, 7),
+ domadapter.getTypedAxisIterator(3, 8)
+ ),
+ domadapter.getTypedAxisIterator(3, 9)
+ )
+ ).setStartNode(i) // *** <line-of-suspicion> ***
+ );
+ make_list(domadapter, nodeiterator, transletoutputhandler, i);
+ ...
+
+ OUTPUT
+ ------
+
+ This week's composers are:
+
+ EXPECTED
+ --------
+
+ This week's composers are:
+ Wolfgang Amadeus Mozart; Guiseppe Verdi; and Giacomo PucciniWolfgang
+ Amadeus Mozart; Guiseppe Verdi; and Giacomo PucciniWolfgang Amadeus Mozart;
+ Guiseppe Verdi; and Giacomo Puccini