Ok, based on Aditya's answer here and on his answer to this question I can now come up with this:
\startbuffer[test]
<?xml version='1.0' standalone='yes?>
<document>
<title>The Title</title>
<author>First Author</author>
<author>Second Author</author>
<p>This is a first sentence</p>
</document>
\stopbuffer
\startxmlsetups xml:setup
\xmlsetsetup{\xmldocument}{*}{-}
\xmlsetsetup{\xmldocument}{document|p}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:setup}
\startxmlsetups xml:document
\xmlfilter{#1}{/title/command(xml:title)}
\xmlfilter{#1}{/author/command(xml:author)}
\startdocument
\xmlflush{#1}
\stopdocument
\stopxmlsetups
\startxmlsetups xml:title
\setupdocument[title={\xmlflush{#1}},author={\AuthorList}]
\stopxmlsetups
\startxmlsetups xml:author
\defineauthor[\xmlflush{#1}][name={\xmlflush{#1}}]
\addtocommalist {\xmlflush{#1}} \AuthorList
\stopxmlsetups
\startxmlsetups xml:p
\xmlflush{#1}\par
\stopxmlsetups
\definenamespace
[documentauthor] % name of internal varialbles
[type=module,
name=author,
command=yes, % Create \defineauthor
style=yes, % Create \useauthorstyleandcolor
setup=list, % Create \setupauthor
parent=documentauthor,
]
\def\AuthorList{}
\define[1]\useauthor
{\edef\currentauthor{#1}%
{\useauthorstyleandcolor{style}{color}
\authorparameter{name}}%
\par
\mono{\authorparameter{email}}
\blank[small]
}
\startsetups document:start
\startalignment[middle]
{\ssbfc\setupinterlinespace
\documentvariable{title}
\endgraf}
\blank[medium]
\processcommacommand[\documentvariable{author}]\useauthor
\blank[big]
\stopalignment
\stopsetups
\setupauthor[style=sansbold]
\xmlprocessbuffer{main}{test}{}
What we do here is:
Define a \defineauthor
command.
Define an empty list for the authors: \def\AuthorList{}
Let <author>
define a new author and add this author to the list of authors.
Make sure the author list is added to the document metadata:
\startxmlsetups xml:title
\setupdocument[title={\xmlflush{#1}},author={\AuthorList}]
\stopxmlsetups
Edit:
A more complete version that also accomodates the author's email could look like this:
\startbuffer[test]
<?xml version='1.0' standalone='yes?>
<document>
<title>The Title</title>
<author>
<name>First Author</name>
<email>author@gmail.com</email>
</author>
<author>
<name>Second Author</name>
<email>author@gmail.com</email>
</author>
<p>This is a first sentence</p>
</document>
\stopbuffer
\startxmlsetups xml:setup
\xmlsetsetup{\xmldocument}{*}{-}
\xmlsetsetup{\xmldocument}{document|author|name|email|p}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:setup}
\startxmlsetups xml:document
\xmlfilter{#1}{/title/command(xml:title)}
\xmlfilter{#1}{/author/command(xml:author)}
\startdocument
\xmlflush{#1}
\stopdocument
\stopxmlsetups
\startxmlsetups xml:title
\setupdocument[title={\xmlflush{#1}},author={\AuthorList}]
\stopxmlsetups
\startxmlsetups xml:author
\defineauthor[\xmlfirst{#1}{/name}][name={\xmlfirst{#1}{/name}},email={\xmlfirst{#1}{/email}}]
\addtocommalist {\xmlfirst{#1}{/name}} \AuthorList
\stopxmlsetups
\startxmlsetups xml:name
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:email
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:p
\xmlflush{#1}\par
\stopxmlsetups
\definenamespace
[documentauthor] % name of internal varialbles
[type=module,
name=author,
command=yes, % Create \defineauthor
style=yes, % Create \useauthorstyleandcolor
setup=list, % Create \setupauthor
parent=documentauthor,
]
\def\AuthorList{}
\define[1]\useauthor
{\edef\currentauthor{#1}%
{\useauthorstyleandcolor{style}{color}
\authorparameter{name}}%
\par
\mono{\authorparameter{email}}
\blank[small]
}
\startsetups document:start
\startalignment[middle]
{\ssbfc\setupinterlinespace
\documentvariable{title}
\endgraf}
\blank[medium]
\processcommacommand[\documentvariable{author}]\useauthor
\blank[big]
\stopalignment
\stopsetups
\setupauthor[style=sansbold]
\xmlprocessbuffer{main}{test}{}
I am not really sure if I haven't introduced new problems, so I'd be happy about comments/edits wherever necessary. (For example, I don't understand why I had to introduce author|name|email
to \xmlsetsetup
, whereas Aditya's solution didn't have author
in \xmlsetsetup
. Also, it is not entirely clear to me how \xmlflush
works. Sometimes I had to use this although a certain XML node is only used by another XML setup, for example email.)