On 8/22/2023 8:53 AM, denis.ma...@unibe.ch wrote:
-----Ursprüngliche Nachricht-----
Von: Hans Hagen via ntg-context <ntg-context@ntg.nl>
Gesendet: Montag, 21. August 2023 19:09

you need a bit of imagination because basically (depends a bit on what you
do) one big nested expansion is going on, as Thomas explained: using setups
which are basically macros. The #1 is the current node (but you can store it in 
a
macro and use it later if needed). So, only references are passed around.

for thomas: we now also have (in lmtx)

\ifxml         {id}{pattern}      \else \fi
\ifxmltext     {id}{pattern}      \else \fi
\ifxmlatt      {id}{name}{value}  \else \fi
\ifxmlattempty {id}{pattern}      \else \fi
\ifxmlempty    {id}{pattern}      \else \fi
\ifxmlselfempty{id}               \else \fi

So, these new commands diverge from the older patterns:
\xmldoifelse{#1}{pattern}{TRUE}{FALSE} ?

they can do the same

Am I reading this correctly?
These are more 'texie' commands avoiding a middle layer. A main difference is that in the case of a \if construction one can have lookahead issues when a command in a branch has to look forward and pick up an argument but that happens seldom in xml (probably never).

\ifxml{#1}{/foo}
  a
\orelse\ifxml{#1}{/ofo}
  b
\orelse\ifxml{#1}{/oof}
  c
\orelse\ifempty{xmlatt{#1}{n}}
  d
% could also be a check for number first:
\orelse\ifnum\xmlattr{#1}{n}>10\relax % of \norelax
  e
\fi

etc (see lowlevel manual) can look a bit less messy that using 5 nested \doifelse's but one has to be aware of the number scanner looking ahead so ending up in the branch because setups have no spaces at the end of lines.

(kind of) think of it like this:

\protected\def\xmldoifelse#1#2%
  {\ifxml{#1}{pattern}%
     \expandafter\firstoftwoareguments
   \else
     \expandafter\secondoftwoareguments
   \fi}

performance wise there is a bit of a difference but i never hear complaints so i guess that matters less

so: just two ways of programming a solution

Hans


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

Reply via email to