Hi,

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"?>
<a5/>


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>
        <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"/>
        </section>
</
section>


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

<?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:hyper
="http://www.hyperbase.com/cosmos/hyper"
        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:for-each>
        </xsl:function>

        <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>
        </xsl:template>

</
xsl:stylesheet>


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.

Regards,

Andre Cusson
ac@hyperbase.com
01 COMMUNICATIONS