On 28 Apr 2016, at 22:13, Pablo Rodriguez <oinos@gmx.es> wrote:

On 04/28/2016 05:06 PM, dr. Hans van der Meer wrote:
Why is there anexpression error here? I would expect that the expression
number(-10000101) evaluates to a negative number taking part in the
comparsion. It looks as if the minus sign is not seen as an unary minus,
while -10000101 should have be evaluated by Lua's tonumber(-10000101).

relevant code snippet is:
\xmlfilter{#1}{lpath[number(@date) <= number(-10000101)]/command(...)

I wouldn’t get it, even with a minimal sample, but xml-mkiv.pdf includes
the shortcut for this function.

Here is a minimal example showing that even a number as -1 is not correctly handled by the lpath[selection]-code.
I really am convinced that not handling negative numbers should qualify as a mistake.

Hans van der Meer


% failure of negative number comparison.
\startxmlsetups demo:numberfail
\xmlsetsetup{#1}{root|node}{demo:numberfail:*}
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{demo:numberfail}
\startxmlsetups demo:numberfail:root
@atta >= 1:\crlf
\xmlfilter{#1}{/[number(@atta) >= 1]/command(demo:numberfail:node)}
\blank
@atta >= -1:\crlf
\xmlfilter{#1}{/[number(@atta) >= -1]/command(demo:numberfail:node)}
\xmlfilter{#1}{/[number(@atta) >= number(-1)]/command(demo:numberfail:node)}
\stopxmlsetups
\startxmlsetups demo:numberfail:node
node: attribute atta = \xmlatt{#1}{atta}\crlf
\stopxmlsetups
\startbuffer[numberfail]
<root>
<node atta="2"/>
<node atta="3"/>
</root>
\stopbuffer
\starttext
\xmlprocessbuffer{demo}{numberfail}{}
the error from \type{\xmlfilter{#1}{/[number(@atta) >= -1]/command(demo:numberfail:node)}}:
\starttyping
xml > lpath > error in expression: number(@atta) >= -1 => expr.number((ll.at and ll.at['atta'])) >= expr.child(ll,'-')1
\stoptyping

the error from \type{\xmlfilter{#1}{/[number(@atta) >= number(-1)]/command(demo:numberfail:node)}}:
\starttyping
xml > lpath > error in expression: number(@atta) >= number(-1) => expr.number((ll.at and ll.at['atta'])) >= expr.number(expr.child(ll,'-')1)
\stoptyping
\stoptext