Hello Efraim,
According to XPath 1.0, "A PredicateExpr
<http://www.w3.org/TR/xpath/#NT-PredicateExpr> is evaluated by
evaluating the Expr <http://www.w3.org/TR/xpath/#NT-Expr> and converting
the result to a boolean. If the result is a number, the result will be
converted to true if the number is equal to the context position and
will be converted to false otherwise; if the result is not a number,
then the result will be converted as if by a call to the *boolean
<http://www.w3.org/TR/xpath/#function-boolean>* function. Thus a
location path |para[3]| is equivalent to |para[position()=3]|."
Thus, I think this is a correct behavior for XSLTForms because a node
has always a text value.
With XPath 2.0, types are associated to values so a number value would
not need a cast.
Thanks!
-Alain
Le 05/09/2011 00:15, Efraim Feinstein a écrit :
> Hi,
>
> I'm attaching a test case for a possible bug in XSLTForms. An indirect
> reference to an item in a nodeset through a numeric index stored in an
> instance fails (by referencing the first item) unless the index is
> explicitly typecast to be a number.
>
> The examples I give are:
> Direct: <xf:output ref="instance('data')//html:ul/html:li[2]"/><br/>
> Indirect (without a cast): <xf:output
> ref="instance('data')//html:ul/html:li[instance('index')/n]"/><br/>
> Indirect (cast to a number): <xf:output
> ref="instance('data')//html:ul/html:li[number(instance('index')/n)]"/>
>
> There are two ways the test in the "Indirect (without a cast)" case
> can be interpreted, though: Take the value, cast it to a number and
> treat it as an index (what I want it to do), or treat the index as a
> node test; if the node exists/is > 0, evaluate to true(), otherwise,
> evaluate to false(). I'm not sure which would be the correct behavior
> in XPath 1.0!
>
> I'm using the latest XSLTForms from svn (rev 508)
>
> Thanks,
>
|