Hi,

Working with 7.9.1, I get this exception while running this stylesheet with this xml file and am a bit puzzeled.
My feeling is that it could be related to the eval fix in 7.9.1 although the eval itself seems to work fine now.
It seems to crash on loop re-evaluation after 2 evals, in some cases ...  Other eval use-cases seem to work fine.
This is a set of xpath queries (ie. $queryseq) to be evaluated on a nodeset variable (ie. $resource) where the basic idea is that evaluation is done in 2 steps:
- first get the target element(s) for the xpath query (ie. $component)
- next, for each element, if required, get the specific attribute(s) requested (ie. $item) and return it(them) in/as a node, otherwise, return the requested element

The single step eval cases seems to work ok.
Other 2 step evaluations also seem to work ok, where it seems to be related to the number of parameter values (ie. $p1, $p2 ...) that are passed to eval (ex: less than 3) ...

Thank you,
Andre



xml file :
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="evaltest.xslt"?>
<go/>


stylesheet :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
        xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs
="http://www.w3.org/2001/XMLSchema"
        xmlns:xdt
="http://www.w3.org/2003/11/xpath-datatypes"
        xmlns:xfn
="http://www.w3.org/2003/11/xpath-functions"
        xmlns:saxon="http://saxon.sf.net/" extension-element-prefixes="saxon"
        xmlns:h
="http://www.xyz.com/h"
        exclude-result-prefixes="h xsl xs xdt xfn saxon"
>
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

        <xsl:variable name="resource">
                <res>
                        <resgrp>
                                <thing id="a" color="red" size="big" weight="heavy"/>
                                <thing id="b" color="green" size="any" weight="any"/>
                                <thing id="c" color="blue" size="small" weight="light"/>
                                <thing id="d" color="red" size="small" weight="heavy"/>
                                <thing id="e" color="green" size="small" weight="heavy"/>
                                <thing id="f" color="blue" size="big" weight="heavy"/>
                                <thing id="g" color="red" size="big" weight="light"/>
                                <thing id="h" color="green" size="small" weight="light"/>
                                <thing id="i" color="blue" size="small" weight="heavy"/>
                        </resgrp>
                </res>
        </xsl:variable>

        <xsl:template match="/">
                <xsl:variable name="queryseq">
                        <aa>red big heavy</aa>
                        <aa>blue small light</aa>
                        <aa>red small light</aa>
                        <aa>green big light</aa>
                </xsl:variable>
                <xsl:message>starting</xsl:message>
                <xsl:for-each select="$queryseq/*">
                        <xsl:message>outer loop cycle begin</xsl:message>
                        <xsl:variable name="parms" select="."/>
                        <xsl:message><xsl:copy-of select="h:getresource('//thing[@color = $p1 and @size = $p2 and @weight = $p3]', '@id', $parms)//@id"/></xsl:message>
                        <xsl:message>outer loop cycle end</xsl:message>
                </xsl:for-each>
                <xsl:message>stoping</xsl:message>
        </xsl:template>

        <xsl:function name="h:getresource">
                <xsl:param name="component"/>
                <xsl:param name="item"/>
                <xsl:param name="params"/>
                <xsl:variable name="para" select="xfn:tokenize($params, ' ')"/>
                <xsl:variable name="xpath-str"><xsl:value-of select="concat('.', $component)"/></xsl:variable>
                <res>
                        <xsl:for-each select="$resource/res">
                                <xsl:message>context set, eval = <xsl:copy-of select="saxon:eval(saxon:expression($xpath-str), $para[1], $para[2], $para[3], $para[4], $para[5], $para[6], $para[7], $para[8], $para[9])"/></xsl:message>
                                <xsl:for-each select="saxon:eval(saxon:expression($xpath-str), $para[1], $para[2], $para[3], $para[4], $para[5], $para[6], $para[7], $para[8], $para[9])">
                                        <xsl:message>element loop = <xsl:value-of select="concat($xpath-str, '/', $item)"/></xsl:message>
                                        <xsl:choose>
                                                <xsl:when test="string-length($item)">
                                                                <xsl:message>return attribute on a node : <item><xsl:copy-of select="saxon:evaluate($item)"/></item></xsl:message>
                                                                <item><xsl:copy-of select="saxon:evaluate($item)"/></item>
                                                </xsl:when>
                                                <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
                                        </xsl:choose>
                                        <xsl:message>hum ... eval seems ok, continue looping if required (and possible) ...</xsl:message>                                                                               
                                
</xsl:for-each>
                        </xsl:for-each>
                </res>
        </xsl:function>

</
xsl:stylesheet>


output & exception :
starting
outer loop cycle begin
context set, eval = <thing id="a" color="red" size="big" weight="heavy"/>
element loop = .//thing[@color = $p1 and @size = $p2 and @weight = $p3]/@id
return attribute on a node : <item id="a"/>
hum ... eval seems ok, continue looping if required (and possible) ...
java.lang.NullPointerException
        at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:162)
        at net.sf.saxon.expr.GeneralComparison.effectiveBooleanValue(GeneralComparison.java:269)
        at net.sf.saxon.expr.BooleanExpression.effectiveBooleanValue(BooleanExpression.java:50)
        at net.sf.saxon.expr.BooleanExpression.effectiveBooleanValue(BooleanExpression.java:50)
        at net.sf.saxon.expr.FilterIterator$NonNumeric.matches(FilterIterator.java:137)
        at net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.java:67)
        at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:48)
        at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:55)
        at net.sf.saxon.instruct.ForEach.processLeavingTail(ForEach.java:57)
        at net.sf.saxon.instruct.Instruction.process(Instruction.java:166)
        at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:208)
        at net.sf.saxon.instruct.ForEach.processLeavingTail(ForEach.java:61)
        at net.sf.saxon.instruct.Instruction.process(Instruction.java:166)
        at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:208)
        at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:183)
        at net.sf.saxon.instruct.Instruction.process(Instruction.java:166)
        at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:208)
        at net.sf.saxon.instruct.Sequence.processLeavingTail(Sequence.java:170)
        at net.sf.saxon.instruct.Instruction.process(Instruction.java:166)
        at net.sf.saxon.instruct.FunctionInstr.call(FunctionInstr.java:132)
        at net.sf.saxon.expr.UserFunctionCall.callFunction(UserFunctionCall.java:214)
        at net.sf.saxon.expr.UserFunctionCall.iterate(UserFunctionCall.java:193)
        at net.sf.saxon.expr.ItemChecker.iterate(ItemChecker.java:79)
        at net.sf.saxon.expr.PathExpression.iterate(PathExpression.java:567)
        at net.sf.saxon.expr.PathExpression.iterate(PathExpression.java:567)
        at net.sf.saxon.sort.DocumentSorter.iterate(DocumentSorter.java:80)
        at net.sf.saxon.instruct.CopyOf.processLeavingTail(CopyOf.java:92)
        at net.sf.saxon.instruct.Instruction.process(Instruction.java:166)
        at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:208)
        at net.sf.saxon.instruct.Message.processLeavingTail(Message.java:79)
        at net.sf.saxon.instruct.Instruction.process(Instruction.java:166)
        at net.sf.saxon.instruct.Instruction.processChildren(Instruction.java:208)
        at net.sf.saxon.instruct.ForEach.processLeavingTail(ForEach.java:61)
        at net.sf.saxon.instruct.Instruction.processChildrenLeavingTail(Instruction.java:269)
        at net.sf.saxon.instruct.Sequence.processLeavingTail(Sequence.java:147)
        at net.sf.saxon.instruct.Template.expand(Template.java:105)
        at net.sf.saxon.instruct.Template.processLeavingTail(Template.java:74)
        at net.sf.saxon.Controller.applyTemplates(Controller.java:302)
        at net.sf.saxon.Controller.run(Controller.java:187)
        at net.sf.saxon.Controller.transformDocument(Controller.java:1536)
        at net.sf.saxon.Controller.transform(Controller.java:1342)
        at net.sf.saxon.Transform.processFile(Transform.java:731)
        at net.sf.saxon.Transform.doMain(Transform.java:435)
        at net.sf.saxon.Transform.main(Transform.java:67)
Fatal error during transformation: null