[ http://issues.apache.org/jira/browse/XALANJ-1933?page=all ]
Brian Minchau updated XALANJ-1933: ---------------------------------- Version: Latest Development Code (was: 2.6) > for-each bug on union of elements returned by key() > --------------------------------------------------- > > Key: XALANJ-1933 > URL: http://issues.apache.org/jira/browse/XALANJ-1933 > Project: XalanJ2 > Type: Bug > Components: transformation, Xalan-interpretive > Versions: Latest Development Code > Environment: Operating System: Windows XP > Platform: PC > Reporter: calvin > Assignee: Xalan Developers Mailing List > > I have encountered an unexpected transform result with Xalan that seems to be > a > bug. I cannot include the entire stylesheet, and I have tried to create a > simple > test case that would show the bug, but I have not been able to reproduce it > in a > simpler transform. I hope this might still be helpful, if only to others > searching the bug database later to see that they aren't the only one that had > the problem. > I have the following template: > <xsl:template name="createParamStatement"> > <xsl:if test="$includeInsertParamMarkers"> > <xsl:text>(</xsl:text> > <xsl:for-each select="key('entityById', @id)/KeyList/Key | > key('entityById', > @id)/PropertyList/Property"> > <xsl:text>?</xsl:text> > <xsl:if test="position() != last()"><xsl:text>, > </xsl:text></xsl:if> > </xsl:for-each> > <xsl:text>)</xsl:text> > </xsl:if> > </xsl:template> > The union expression in the xsl:for-each returns multiple Key and Property > elements. If I run my transform as is above, I get the following output, > regardless of how many elements were actually being iterated over: > (?,) > It shows the correct xsl:text for the first element matched, and then prints > the > comma text, which should only happen if it's not the last element, but the > '?' > text doesn't get printed again. > If, on the other hand, I assign the nodes returned by the union expression to > a > variable, and iterate on the for-each through the node set in the variable, I > get the correct output: > (?,?,?,?) {or whatever} > So, to summarize, the behavior that I'm seeing is that > <xsl:for-each select="key('someKey', @id)/Key | key('someKey', @id)/Prop"> > <xsl:text>?</xsl:text> > <xsl:if test="position() != last()">, </xsl:if> > </xsl:for-each> > behaves differently than does > <xsl:variable name="returnedElems" select="key('someKey', @id)/Key | > key('someKey', @id)/Prop"/> > <xsl:for-each select="$returnedElems"> > <xsl:text>?</xsl:text> > <xsl:if test="position() != last()">, </xsl:if> > </xsl:for-each> > In my failing transform, the key referenced is defined in an imported > stylesheet. I've tried some simple transforms like above with an imported key, > but have not been able to reproduce the problem. In the full trasnform, the > template that behaves strangely is called from within another template, in the > following context: > <xsl:for-each > select="descendant-or-self::[EMAIL PROTECTED]($parent2ThisType)]|."> > <xsl:if test="not($mode='dependencyMode' and not(@parent2ThisType))"> > <!-- do a bunch of other stuff --> > <xsl:variable name="paramMarkers"> > <xsl:call-template name="createParamStatement"/> > </xsl:variable> > <!-- do a bunch more stuff --> > <xsl:value-of select="concat($someOtherVar, ": ", $paramMarkers)"/> > </xsl:if> > </xsl:for-each> > To repeat, the behavior I'm seeing is that a union inside a for-each's select > is > behaving different than first binding the union results to a variable and > passing the variable reference to the for-each's select. > Saxon behaves the same in both cases, and outputs the correct results (a > comma-separated list of '?' with no comma after the last '?'), and xalan-j > 2.6.0 > behaves correctly if I assign to a variable first, but if I don't assign to a > variable, it prints only one '?' (which is mistake number 1) and ends the list > with a comma (which is mistake number 2, since comma shouldn't be output after > last elem), which implies to me that perhaps the select is iterating through > multiple nodes but only executing inside the for-each on the first node in the > select. > I'm sorry I can't give the entire failing stylesheet, but I am not allowed to. > If you need more information, I'm happy to answer any questions about the > failing transform and the context. I'll try more to create a simple failing > test > case, but I couldn't get one to fail right now and can't spend more time on it > at the moment. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]