DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11182>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11182 Variable expansion in nested stylesheet produces erroneous results Summary: Variable expansion in nested stylesheet produces erroneous results Product: XalanC Version: 1.2.x Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: XalanC AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] This is my first bug report, so be gentle :) Using Xalan-C++ 1.2 on Windows NT, I'm encountering a bewildering problem. Here are the stylesheets and associated XML, pared down to something that's reasonable to debug. The full stylesheets actually do something, but these exhibit the problem without a lot of noise. 4 XSLT files: row.xslt, tab.xslt, xtab.xslt and dimbar.xslt. Dimbar.xslt includes the other three. ---- DIMBAR.XSLT ----- <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:variable name="imgPath" select="string('crq/images/')"/> <xsl:variable name="POSITION_OFFSET" select="0"/> <xsl:template match="/"> <html> <head> <title>Dimension Bar</title> </head> <body> <xsl:apply-templates select="/data/tab"> <xsl:with-param name="number" select="position ()-$POSITION_OFFSET"/> </xsl:apply-templates> </body> </html> </xsl:template> <xsl:include href="xtab.xslt"/> <xsl:include href="tab.xslt"/> <xsl:include href="row.xslt"/> </xsl:stylesheet> ---- DIMBAR.XSLT ----- ---- TAB.XSLT ----- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="tab"> <xsl:param name="number"/> <xsl:apply-templates select="crosstab"> <xsl:with-param name="tabnum" select="$number"/> </xsl:apply-templates> </xsl:template> </xsl:stylesheet> ---- TAB.XSLT ----- ---- XTAB.XSLT ----- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="crosstab"> <xsl:param name="tabnum"/> <xsl:variable name="xtabnum" select="count(following-sibling::crosstab) + 1"/> <xsl:for-each select="rows/row"> <xsl:call-template name="row"> <xsl:with-param name="pos" select="count(preceding- sibling::*/descendant::*[count(row) = 0])"/> <xsl:with-param name="levelnumber" select="0"/> <xsl:with-param name="tabnum" select="$tabnum"/> <xsl:with-param name="xtabnum" select="$xtabnum"/> <xsl:with-param name="mainRow" select="position()-1"/> </xsl:call-template> </xsl:for-each> </xsl:template> </xsl:stylesheet> ---- XTAB.XSLT ----- ---- ROW.XSLT ----- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="row"> <xsl:param name="pos"/> <xsl:param name="levelnumber"/> <xsl:param name="tabnum"/> <xsl:param name="xtabnum"/> <xsl:param name="mainRow"/> <xsl:variable name="rowpos" select="position()-1"/> <p onclick="selectRowLevel ( '{$tabnum}', '{$xtabnum}','{$rowpos}');">Test</p> </xsl:template> </xsl:stylesheet> ---- ROW.XSLT ----- And here's the file to transform... ---- XML DATA ----- <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="http://wotthiltzj/atlantic/ppwb/crq/dimbar.xslt"?> <data> <tab> <crosstab> <rows> <row/> <row/> <row/> </rows> </crosstab> </tab> </data> ---- XML DATA ----- When passed to Xalan using the "transform" method of the XalanTransformer object, the resulting HTML looks like so: ---- HTML RESULT----- <html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Dimension Bar</title> </head> <body> <p onclick="0');">Test</p> <p onclick="0', '1','1');">Test</p> <p onclick="0', '1','2');">Test</p> </body> </html> ---- HTML RESULT----- Notice the expansion of (what appears to be) the third variable in the onclick attribute of the first <p> tag. And for the subsequent two <p> tags, the first variable seems to be expanded incorrectly. It's like it's missing the first "{" and replacing until it finds the beginning of the attribute. Even more interesting is the fact that if I declare the offending variable in row.xslt like so(see below), the problem goes away! BAD --- <xsl:variable name="rowpos" select="position()-1"/> GOOD ---- <xsl:variable name="rowpos"> <xsl:value-of select="position()-1"/> </xsl:variable> I've thrown it at IE 6.0, and it seems to produce the proper (or at least, what I would expect...) as results. Hope that's info to reproduce it. Don't hesitate to email if you have any questions. Cheers, Jason [EMAIL PROTECTED]
