Dear Context’ers,

I am trying to use the letter module in mkiv for typesetting serial letters 
from an xml database.

Thanks, Thomas for looking into this. I appreciate it very much. Yet I don’t 
know either whether I actually need the letter module, but it seemed reasonable 
to try this first.

Today I tried to insert some simple luatex code which I found on another forum.

The results are promising:

a. The address appears.
b. The salutation + formalname also appear.

Yet there are some problems:

1. the address elements appear in one line, not underneath as desired,
2. When I add text such as Knuth or references to the database, Context stops.

See the code below.

My question at this point is: how can I proceed? Do I actually need the letter 
module?

Kind regards,

Robert

Attachment: brieven2mkiv.pdf
Description: Adobe PDF document


\usemodule[letter]

\starttext
\startbuffer[participants]
<?xml version="1.0" encoding="UTF-8"?>
<document>
<contacts>
<contact class='participant' label='Hendriks'>
    <formalname>Hendriks</formalname>
    <informalname>Karel</informalname>
    <prefix>mr.</prefix>
    <initials>K.</initials>
    <courselevel>levelA</courselevel>
    <coursedate>1 june 2017</coursedate>  
    <city>Arnhem</city>
    <address>
      <p>Mr. K. Hendriks</p>
      <p>Grotestraat 5</p>
      <p>1234 Arnhem</p>
    </address>
  </contact>

  <contact class='participant' label='Janssen'>
    <formalname>Janssen</formalname>
    <informalname>Piet</informalname>
    <initials>P.</initials>
    <prefix>mr.</prefix>
    <courselevel>levelA</courselevel>
    <coursedate>1 june 2017</coursedate>  
    <city>Nijmegen</city>
    <address>
     <p>Mr. P. Janssen</p>
     <p>Kortestraat 8</p>
     <p>1234 Nijmegen</p>
    </address>
  </contact>
</contacts>
</document>

\stopbuffer

\startxmlsetups xml:setups
\xmlsetsetup{#1}{contacts|contact|address|prefix}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:setups}

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

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

\startxmlsetups xml:contact

\defineletterelement[layer][address][example]%
       {\correspondenceparameter{toname}\\
       \correspondenceparameter{toaddress}
       \par}
       
   \setupletterlayer[address][alternative=example]

\startletter
  [opening={{Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname},}},
   closing={Kind regards,},
   signature={Sender},
   toaddress={{\xmltext{#1}{/address}}},
   subject={Interesting offer}]

%\input knuth

%{\xmltext{#1}{/informalname}}
%\xmltext{#1}{/address/p}

\stopletter

\stopxmlsetups

\startluacode
userdata = userdata or { }
userdata.letter = { }
\stopluacode


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


> Op 18 jun. 2017, om 17:33 heeft Thomas A. Schmitz 
> <[email protected]> het volgende geschreven:
> 
> On 06/15/2017 11:58 PM, [email protected] wrote:
>> Thusfar I have been trying to use the letter module with the xmltext and 
>> xmlflush commands. What can be done to make this work?
>> Thanks!
> 
> I'm sorry, I don't use the letter module and don't have it installed. As far 
> as I can see, your way of using the xml commands is correct. There appears to 
> be some sort of incompatibility between the letter module and xml, but I 
> guess only Wolfgang (the author of the module) can really say what's going 
> on. If you want to typeset simple letters, maybe you can bypass the module?
> 
> Thomas

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

maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to