\usemodule[letter]
\setuplanguage[nl][date={year, –, mm, –, dd}] % ISO 8601 date
\setupletteroptions[language=netherlands,bodyfont={rm,10pt},whitespace=1.5ex]
\startbuffer[participants]
<contacts>
<contact class='participant' label='Hendriks'>
<formalname>Hendriks</formalname>
<informalname>Karel</informalname>
<prefix>mr.</prefix>
<initials>K.</initials>
<city>Arnhem</city>
<address>
<p>Mr. K. Hendriks</p>
<p>Grotestraat 5</p>
<p>1234 BB Arnhem</p>
</address>
<kix>1234bb5</kix>
</contact>
<contact class='participant' label='Janssen'>
<formalname>Janssen</formalname>
<informalname>Piet</informalname>
<initials>P.</initials>
<prefix>mr.</prefix>
<city>Nijmegen</city>
<address>
<p>Mr. P. Janssen</p>
<p>Kortestraat 8</p>
<p>1234 AA Nijmegen</p>
</address>
<kix>1234aa8</kix>
</contact>
</contacts>
\stopbuffer
\startxmlsetups xml:setups
\xmlsetsetup{#1}{document|contacts|contact|prefix|initials|address|city|text|kix|p}{xml:*}
%\xmlsetsetup{\xmldocument}{text:p}{xml:paragraph}
\stopxmlsetups
\xmlregistersetup{xml:setups}
\startxmlsetups xml:contacts
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:contact
\setupletter
[toaddress={\xmlall{#1}{/address/p}\par\xmltext{#1}{/kix}}]
\defineletterelement[layer][address][example]%
{\correspondenceparameter{toname}\\\correspondenceparameter{toaddress}\par}
%toname is not used in setupletter because toaddress contains all data.
%kix is used for adding a barcode to the address.
\setupletterlayer[address][alternative=example,y=6cm,x=12cm,color=red,style=\tfa\sans]
\startletter
[opening={Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname},},
closing={Kind regards,},
subject={subject: your life in \xmltext{#1}{/city}},
signature={X}]
\stopletter
\stopxmlsetups
\startxmlsetups xml:address
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:p
\xmlflushtext{#1}\par
\stopxmlsetups
\starttext
%\input knuth
%tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst tekst
\xmlprocessbuffer{main}{participants}{}
\stoptext