Thanks for reporting this. It's another variant of
In, line 114, after
            expr = expr.analyze(staticContext);

            ExpressionTool.allocateSlots(expr, 1);
I'll add your repro to my test cases - thanks for narrowing it down so tightly.
Michael Kay
-----Original Message-----
From: [] On Behalf Of Andre Cusson
Sent: 21 February 2004 04:21
Subject: [saxon] eval params and conditions


Something strange seems to be happening with saxon:eval in Saxon 7.8 and I can't yet figure out why.

I have a simple source file called debug.xml :

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

a lookup file (res.xml) read by the stylesheet (in $res).  The main caracteristic is that 2 elements in this file can have the same "id", if they have a different "class".  These elements are looked up by checking both attribute values.

<?xml version="1.0" encoding="ISO-8859-1"?>
<section class="res">
        <section class="company">
                <entity class="company" id="a0"/>
                <entity class="company" id="a1"/>
                <entity class="company" id="a2"/>
                <entity class="company" id="a3"/>
                <entity class="company" id="a4"/>
                <entity class="company" id="a5"/>
                <entity class="company" id="a6"/>
                <entity class="company" id="a7"/>
                <entity class="company" id="a8"/>
                <entity class="company" id="a9"/>
        <section class="address">
                <entity class="address" id="a0"/>
                <entity class="address" id="a1"/>
                <entity class="address" id="a2"/>
                <entity class="address" id="a3"/>
                <entity class="address" id="a4"/>
                <entity class="address" id="a5"/>
                <entity class="address" id="a6"/>
                <entity class="address" id="a7"/>
                <entity class="address" id="a8"/>
                <entity class="address" id="a9"/>

and a stylesheet (debug.xslt) to lookup elements in $res :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
        xmlns:saxon="" extension-element-prefixes="saxon"
        exclude-result-prefixes="hyper xsl xs xdt xfn saxon"
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="res" select="document('file:///res.xml')/*"/>
<xsl:function name="hyper:getres">
                <xsl:param name="xpathstr"/>
                <xsl:param name="params"/>
                <xsl:variable name="para" select="xfn:tokenize($params, ' ')"/>
                <xsl:for-each select="$res">
                        <res><xsl:copy-of select="saxon:eval(saxon:expression($xpathstr), $para[1], $para[2], $para[3], $para[4], $para[5], $para[6], $para[7], $para[8], $para[9])"/></res>

        <xsl:template match="*">
                <xsl:message>only p1 : <xsl:copy-of select="hyper:getres('.//entity[@id = $p1]', concat(name(), ' ', 'company'))"/></xsl:message>
                <xsl:message>only p2 : <xsl:copy-of select="hyper:getres('.//entity[@class = $p2]', concat(name(), ' ', 'company'))"/></xsl:message>
                <xsl:message>p1 + p2 : <xsl:copy-of select="hyper:getres('.//entity[@id = $p1 and @class = $p2]', concat(name(), ' ', 'company'))"/></xsl:message>
                <xsl:message>static : <xsl:copy-of select="$res//entity[@id = name(current()) and @class = 'company']"/></xsl:message>


As the match="*" template shows, if the two conditions are applied simultaneously (see: 'p1 + p2'), no elements from $res are returned, but each condition (see: 'only p1' and 'only p2') individually works fine.  It seems to me that the combination should also work. What am I doing wrong ?

Of course, in this simplified sample, I could lookup $res elements without using saxon:eval, directly with xpath (see: 'static'), where everything seems to work fine, but all this is used in a more complex application where saxon:eval is required.

Thank you.


Andre Cusson