Greetings,
I'm typesetting an address book whose addresses are in XML. A typical entry has this structure:
<family surname="">
<address street="" housenumber="" postcode="1" city="" telephone="" />
<members>
<member first_name="" initials="" maiden_name="" birthday="" email="" mobile="" />
<member first_name="" initials="" birthday="" email="" mobile="" />
<member first_name="" initials="" birthday="" />
</members>
</family>
initials and birthday are required, first_name can be left blank and email, mobile and maiden_name are optional.
I've written a macro (name) to compose the name, i.e. initials, first_name (maiden_name), and another macro (nameemaillink) to make the name a link associated with an email address.
% Derive an individual's name
\def\name#1%
{\ifxmlattempty{#1}{first_name} {\xmlatt{#1}{initials}} \else {\xmlatt{#1}{initials}, \xmlatt{#1}{first_name}} \fi
\ifxmlattempty{#1}{maiden_name} {} \else { \tfxx(\xmlatt{#1}{maiden_name})} \fi}
% Create a mailto:
link that associates a individual's name with their email address.
\def\nameemaillink#1%
{\ifxmlattempty{#1}{email} {\name{#1}} \else {\goto{\name{#1}} [url(mailto:\xmlatt{#1}{email})]} \fi}
I thought I was done when I noticed that a composed name with an empty first name, with or without an email address, is slightly indented. In the mwe Moe and Curly, without first names, are indented; while Shemp and Michael aren't.
That the undesired indentation/alignment is dependent on the presence of a first name is baffling. After this long description, if someone would look at the code and tell me where I've gone wrong I would be very grateful. The interesting bits begin on lines 8 and 12 in xml.tex.
-- With kind regards,
Michael