Re: [NTG-context] xml: test for attribute

2010-12-13 Thread Hans Hagen

On 13-12-2010 8:58, Thomas Schmitz wrote:

Hi all,

I thought I had done this and it was easy, but I can't find a solution:
I want to test whether a xml tag has an attribute and vary the typeset
content accordingly. There used to be \xmldoifelseempty, but that has
been commented out (lxml-ini.mkiv). What else could I use? Here's a
small test that shows what I'm trying to do:

\startbuffer[test]
a
bsome text/b
b important=differentmore text/b
/a
\stopbuffer

\startxmlsetups xml:testsetups
\xmlsetsetup{\xmldocument}{a|b}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}

\startxmlsetups xml:a
\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:b
\xmldoifelse{#1}{./[...@important]}
%\doifemptyelse{\expanded{\xmlatt{#1}{important}}}


something like this:

\doifelse {\xmlatt{#1}{important}} {} {
  \color[darkblue]{EMPTY: \xmlflush{#1}}
} {
  \color[darkred]{NOTEMPTY: \xmlatt{#1}{important}}
}
\par

or (untested): \xmldoifelse{#1}{./[...@important==''])

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | 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 / 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
___


Re: [NTG-context] xml: test for attribute

2010-12-13 Thread Thomas Schmitz

Hans, thanks a lot!

On Mon, 13 Dec 2010 21:17:23 +0100
 Hans Hagen pra...@wxs.nl wrote:


something like this:

\doifelse {\xmlatt{#1}{important}} {} {
  \color[darkblue]{EMPTY: \xmlflush{#1}}
} {
  \color[darkred]{NOTEMPTY: \xmlatt{#1}{important}}
}
\par

Yes, this works!



or (untested): \xmldoifelse{#1}{./[...@important==''])


This doesn't, for some reason. But I'm glad to see that my 
syntax wasn't too far off. Thanks a lot, and all best!


Thomas
___
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
___