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=14870>. 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=14870 Parameter value lost when traversing different context Summary: Parameter value lost when traversing different context Product: XalanJ2 Version: 2.4 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Blocker Priority: Other Component: Xalan AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] input XML: <?xml version="1.0" encoding="UTF-8"?> <page type="menu"> <menu> <diagnosis type="Diagnosis" authorization="Read, Write, Update, Delete, Control, Review, Lock, Admin" collection_id="44" screenName="diagnosis" keyName="personId" parent_folder="false" from_data="true" title="Diagnosis"> <diagnosisSite type="Diagnosis sites" authorization="Read, Write, Update, Delete, Control, Review, Lock, Admin" collection_id="199" screenName="diagnosis_site" keyName="diagnosisId" parent_folder="false" from_data="false" title="Diagnosis sites"/> </diagnosis> </menu> <root_keys> <personId value="401250"/> </root_keys> <data> <diagnosis> <personId dataCollectionId="428" value="401250"/> </diagnosis> <diagnosisSite> <diagnosisId dataCollectionId="442" value="428"/> <diagnosisId dataCollectionId="441" value="428"/> </diagnosisSite> <diagnosis> <personId dataCollectionId="434" value="401250"/> </diagnosis> <diagnosisSite> <diagnosisId dataCollectionId="443" value="434"/> </diagnosisSite> </data> </page> input XSLT: <?xml version='1.0' encoding='utf-8' ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output encoding="utf-8" method="xml" indent="no"/> <xsl:strip-space elements="*"/> <xsl:template match="page"> <xsl:copy> <xsl:apply-templates select="*"/> </xsl:copy> </xsl:template> <xsl:template match="menu"> <xsl:variable name="nodename" select="local-name(*)"/> <!-- should always have only one immeadiate child, local-name() picks first in any case --> <xsl:variable name="keyname" select="/page/data/*[local-name() = $nodename]/*[1]"/> <!-- should be only one child... --> <xsl:copy> <xsl:apply-templates select="*" mode="submenu"> <xsl:with-param name="parentKey" select="/page/root_keys/*[local-name() = local-name($keyname)]/@value"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="*" mode="menu"> <xsl:param name="parentKey" select="."/> <xsl:variable name="context" select="."/> <xsl:copy> <xsl:for-each select="/page/data/*[local-name() = local-name ($context)]/*"> <xsl:element name="{local-name($context)}"> <xsl:if test="$context/*"> <xsl:variable name="curKey" select="current()/@dataCollectionId"/> curKey=<xsl:value-of select="$curKey"/> <xsl:apply-templates select="$context/*" mode="submenu"> <xsl:with-param name="parentKey" select="$curKey"/> </xsl:apply-templates> </xsl:if> </xsl:element> </xsl:for-each> </xsl:copy> </xsl:template> <xsl:template match="*" mode="submenu"> <xsl:param name="parentKey"/> parentKey=<xsl:value-of select="$parentKey"/> <!-- This value is lost with Xalan 2.3.1 and above --> <xsl:variable name="type"><xsl:value-of select="@type"/></xsl:variable> <xsl:variable name="prev_type"><xsl:value-of select="preceding- sibling::*[1]/@type"/></xsl:variable> <xsl:apply-templates select="." mode="menu"> <xsl:with-param name="parentKey" select="$parentKey"/> </xsl:apply-templates> </xsl:template> </xsl:stylesheet> Expected results properly output with Saxon, MSXML3, MSXML4. No "parentKey" value output with Xalan 2.3.1 or 2.4.0. Similar exists problem if using named templates, pass context as variable and use a "for-each" to handle each item in turn. In this case, the variable is ok before the "for-each" and lost as soon as the "for-each" is entered.
