I am typesetting a very simple address list whose source is written in
XML.  Typesetting choices need to be made dependent on the presence of
various attributes; consider the following <family> element.

<family surname="Boer" prefix="den">

If the prefix attribute exists I'l like the name to appear as, e.g. 'Boer,
den."  The several XML attribute testing functions in the XML manual appear
to discriminate on an attribute's value. I tried  \xmldoifnotatt in an
attempt to say, "TRUE if prefix does not match an empty string",  since I
am not interested in the attribute's value but only whether or not it
exists. The code below doesn't work. If someone who knows why it doesn't
work would enlighten my ignorance I would be most grateful. A brief
explanation and example of \xmldoifatt, \xmldoifnotatt, and \xmldoifelseatt
would be exceedingly helpful.

\startxmlsetups xml:list:family
  {\bf \xmlatt{#1}{surname} \xmldoifnotatt{#1, prefix, ''} {,
\xmlatt{#1}{prefix}}} \crlf

I have attached three files below: an XML address list, the ConTeXt source
file and the typeset result.

With kind regards,

Michael Guravage
<?xml version="1.0" encoding="utf-8"?>


  <family surname="Horwitz" prefix="">
    <address street="Bowery" housenumber="42-1" postcode="10003" city="New York"  telephone="(934) 012-3456" />
      <member name="Jerome (Curly)" birthday="22.11.1903" email="cu...@stooges.com" mobile="(934) 123-4567" />
      <member name="Moses (Moe)" birthday="10.06.1897" email="m...@stooges.com" mobile="(934) 234-5678" />
      <member name="Samuel (Shemp)" birthday="11.03.1895" email="sh...@stooges.com" mobile="(934) 345-6789" />

  <family surname="Feinberg" prefix="den">
    <address street="Bowery" housenumber="42-2" postcode="10003" city="New York"  telephone="(934) 012-3456" />
      <member name="Louis (Lary)" birthday="05.10.1902" email="la...@stooges.com" mobile="(934) 456-7890" />
      <member name="Mabel" maiden_name="Haney" birthday="05.21.1904" email="ma...@stooges.com" />

\startxmlsetups xml:list:base


\startxmlsetups xml:list:addressBook
  \title{Address List}

\startxmlsetups xml:list:family
  %% {\bf \xmlatt{#1}{surname} \xmldoifnotatt{#1, prefix, ''} {, \xmlatt{#1}{prefix}}} \crlf
  {\bf \xmlatt{#1}{surname}}\crlf

\startxmlsetups xml:list:address
  \xmlatt{#1}{street} \xmlatt{#1}{housenumber}\crlf

\startxmlsetups xml:list:members

\startxmlsetups xml:list:member
 \NC \xmlatt{#1}{name} {\tfxx \xmlatt{#1}{maiden_name}} \NC \xmlatt{#1}{birthday} \NC \xmlatt{#1}{email} \NC \xmlatt{#1}{mobile} \NC\NR


Attachment: stooges.pdf
Description: Adobe PDF document

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

maillist : ntg-context@ntg.nl / 
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net

Reply via email to