Re: xpath filtering extension function called too many times

Adrian Herscu <[email protected]> Tue, 22 Jun 2010 15:49:54 +0300
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
Hmmm... Then having

     <xsl:variable name="sections">
       <xsl:for-each select="descendant::section">
         <xsl:copy>
           <xsl:copy-of select="@* />
         </xsl:copy>
       </xsl:for-each>
     </xsl:variable>


$node-set := xalan:nodeset($sections)/section
for each node in $node-set do
     apply the filter [utils:dummy(true())][1] to the node in the node-set
done

Should behave the same. But it does not.
???

Regards,
Adrian.

On 22/06/2010 15:10, Mukul Gandhi wrote:
> On Tue, Jun 22, 2010 at 2:03 PM, Adrian Herscu<[email protected]>  wrote:
>>   1. xsl variables:
>>
>> <xsl:variable name="sections" select="descendant::section" />
>>
>> and then use this XPath expression instead
>>
>> xalan:nodeset($sections)[utils:dummy(true())][1]
>>
>> then the dummy() function will be called 4 times (while the output xml will
>> remain the same) !
>
> I'm tempted to imagine, that Xalan might be trying to do as following
> (written as pseudo-code), for the above case:
>
> $node-set := xalan:nodeset($sections)
> for each node in $node-set do
>      apply the filter [utils:dummy(true())][1] to the node in the node-set
> done
>
> Which I think will likely cause the expression, utils:dummy(true()) to
> be evaluated as many times as the number of nodes in the node-set.
>
> I think, to be able to evaluate utils:dummy(true()) only once, the
> processor needs to do some hard static analysis of the expression,
> which could an implementation constraint.
>
>