* evaluation of != and ~=
@ 2016-04-29 15:26 Meer, Hans van der
0 siblings, 0 replies; only message in thread
From: Meer, Hans van der @ 2016-04-29 15:26 UTC (permalink / raw)
To: NTG ConTeXt
[-- Attachment #1.1: Type: text/plain, Size: 1372 bytes --]
This one took the better part of an afternoon from me, but I finally found the (unexpected) culprit.
In the xml documentation on page 31 it is said:
The given expression between [] is converted to a LUA expression so you can use the use operators: == ~= <= >= < > not and or ()
In addition, = equals == and != is the same as ~=.
This is not true as the following demonstrates. The use of != is as expected but the ~= leads to an error and this should not be:
xml> lpath > error in expression: number(@atta) ~= 1 => expr.number((ll.at<http://ll.at> and ll.at<http://ll.at>['atta'])) ~== 1
Hans van der Meer
% failure of test on inequality.
\startxmlsetups demo:comparefail
\xmlsetsetup{#1}{root|node}{demo:comparefail:*}
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{demo:comparefail}
\startxmlsetups demo:comparefail:root
compare \type{!=}\crlf
\xmlfilter{#1}{/[number(@atta) != 1]/command(demo:comparefail:node)}
compare \type{~=}\crlf
\xmlfilter{#1}{/[number(@atta) ~= 1]/command(demo:comparefail:node)}
\stopxmlsetups
\startxmlsetups demo:comparefail:node
node: attribute atta = \xmlatt{#1}{atta}\crlf
\stopxmlsetups
\startbuffer[comparefail]
<root>
<node atta="2"/>
<node atta="1"/>
</root>
\stopbuffer
\starttext
\xmlprocessbuffer{demo}{comparefail}{}
Note the absence of output in the second \tex{xmlfilter}.
\stoptext
[-- Attachment #1.2: Type: text/html, Size: 3958 bytes --]
[-- Attachment #2: xml-compare.pdf --]
[-- Type: application/pdf, Size: 8931 bytes --]
[-- Attachment #3: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-29 15:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 15:26 evaluation of != and ~= Meer, Hans van der
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).