Dear Contex’ers,

This morning I have been experimenting with the solutions suggested by Thomas and Wolfgang.

Thomas’ solution works, it produces two distinct letters, yet the address is probably on another layer. This means that it is not shifted to the right, at least not with the command (\setupletterlayer[address]), so that it will be visible through the envelope window.

With Wolfgang’s solution the address is moved to its desired place, and the letter text is printed as well.

However, inserting a text (by means of \input) is problematic (see pdf), with or without \relax.

I then experimented with alternatives like \startbuffer[lettercontent] … endbuffer. The \input problem remains: it appears that the buffer takes any command (\foo) as literal text.

I tried moving the setbuffer … endbuffer part to elswhere in the document. I also experimented with \input a sample text of my own on my harddisk. I tried deleting the \placeletter command - no difference.

So, I feel I am close, but not yet there, one more step …

Robert




\usemodule[letter]

\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:*}
\stopxmlsetups

\xmlregistersetup{xml:setups}

\setuplettersection[content][alternative=setups]

\startsetups[letter:layer:address]
   \correspondenceparameter{toname}\\
   \correspondenceparameter{toaddress}
\stopsetups

\setuplettertext[en][date=]
\setuplettertext[nl][date=]

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

\startxmlsetups xml:p
\xmlflushtext{#1}\par
\stopxmlsetups

\setupletterlayer
 [address]
 [alternative=setups,
  y=6cm,
  x=12cm,
  color=red,
  style=\ss\tfa]

\startsetups[letter:section:content]
   \getbuffer[lettercontent]
\stopsetups

%\startbuffer[lettercontent]
%content of the letter \xmltext{#1}{/city}
%\input knuth \relax
%\stopbuffer

\startxmlsetups xml:contact
   \setupletter
     [toaddress={\xmlall{#1}{/address/p}\par
     \xmltext{#1}{/kix}},
        opening={Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname},},
        closing={Kind regards,},
        subject={subject: your life in \xmltext{#1}{/city}},
      signature={Herman}]

\setbuffer[lettercontent]
%This is the content of the letter.
\input knuth \relax
\endbuffer

\placeletter

\stopxmlsetups

\setuppagenumbering [state=stop]

\starttext
\xmlprocessbuffer{main}{participants}{}
\stoptext