[
https://issues.apache.org/jira/browse/XALANJ-2389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12529600
]
Brian Minchau commented on XALANJ-2389:
---------------------------------------
Here is the XML for a testcase:
<a><x><y>3</y><y>5</y><y>1</y></x></a>
Here is the stylesheet for the same testcase:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="v" select="3"/>
<!-- These 3 are OK even without the patch -->
<xsl:variable name="var1" select="351"/>
<xsl:variable name="var2" select="a"/>
<xsl:variable name="var3" select="a[//x/y[3]]"/>
<!-- This one with var4 only works with the patch -->
<xsl:variable name="var4" select="a[//x/y[$v]]"/>
<out><xsl:value-of
select="$var1 + 1"/>,<xsl:value-of
select="$var2 + 1"/>,<xsl:value-of
select="$var3 + 1"/>,<xsl:value-of
select="$var4 + 1"/></out>
</xsl:template>
</xsl:stylesheet>
The correct output is:
<out>352,352,352,352</out>
Note that this is an XSLTC problem, it works fine for the interpreter.
> XSLTC doesn't correctly set the parent of some nodes ... comile time failures
> result
> ------------------------------------------------------------------------------------
>
> Key: XALANJ-2389
> URL: https://issues.apache.org/jira/browse/XALANJ-2389
> Project: XalanJ2
> Issue Type: Bug
> Components: XSLTC
> Reporter: Brian Minchau
>
> There is a problem with AST node construction in XSLTC.
> When the processor is creating AST nodes for path expressions,
> it sometimes discards nodes that it creates, takes the child nodes,
> and attaches them to new parents. This can happen when nodes
> representing casts are injected.
> Inside the constructors and various setter methods for SyntaxTreeNode
> and its subclasses, there are calls to setParent that try to ensure that the
> child of a node points to its parent. The problem is that
> SyntaxTreeNode.setParent checks whether the parent of a node is not null,
> and if it is, it ignores the request to set the parent.
> In the case of the path expressions, some nodes that the parser has already
> created as children of other nodes get reattached to new parents in the
> middle of parsing.
> The behaviour of the setParent method means that such nodes point to the old
> parent
> which is disconnected from the rest of the parse tree.
> Much later, when generating code for VariableReference nodes,
> we loop through the parent chain looking for the nearest ancestor
> that implements the Closure interface. Predicate is one such class.
> But this problem in SyntaxTreeNode.setParent has the result that the
> variable reference node in the test case does not find a Predicate that
> ought to be in its ancestor chain.
> The problem is to ensure the SyntaxTreeNode._parent pointer is correct.
> It's not a simple matter of changing SyntaxTreeNode.setParent to
> unconditionally set the _parent field however. If you do that, other things
> end up being broken.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]