Re: [xsl] Implementing XPointer Resolution With saxon:evaluate()

Subject: Re: [xsl] Implementing XPointer Resolution With saxon:evaluate()
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Aug 2002 16:26:03 +0100
Hi Eliot,

I'm a bit worried about this part of your xindrf:resolve-xpointer()
function:

>       <xsl:variable name="direct-result-set"
> select="saxon:evaluate($xpointer)"/>
>       <xsl:for-each select="$direct-result-set">
>         <xsl:choose>
>           <xsl:when test="self::xindr:indirector and
> ($indirector-treatment-str != 'as-resource')" >
>             <func:result select="xindrf:resolve-indirector(.)"/>
>           </xsl:when>
>           <xsl:otherwise>
>             <func:result select="."/>
>           </xsl:otherwise>
>         </xsl:choose>
>       </xsl:for-each>

One of the rules about EXSLT function definitions is that the
processor must only encounter one func:result instruction when
evaluating the function body. This is to preserve the usual
side-effect-free nature of XSLT (and is why func:result is called
func:result rather than func:return).

It looks to me here as if it could be possible for $direct-result-set
to hold any number of nodes, which would mean that you would get
multiple func:result instructions, which would be an error. To prevent
that, you should use:

  <xsl:for-each select="$direct-result-set[1]">
    ...
  </xsl:for-each>

or (if you want to be able to handle multiple points), rejig the code
so that you use recursion to collect together all the nodes that you
want to return from the function.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread