ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Schmitz Thomas A." <thomas.schmitz@uni-bonn.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: letters in context mkiv
Date: Sun, 30 Jul 2017 17:38:29 +0200	[thread overview]
Message-ID: <41B71466-27DF-4CCD-9767-15EB58FB1723@uni-bonn.de> (raw)
In-Reply-To: <68556476-40FF-4279-8DB1-19BB681730BB@hccnet.nl>


> On 30. Jul 2017, at 14:15, r.ermers@hccnet.nl wrote:
> 
> Let me as a turcologist compare my problem to learning Kazakh: I am prepared to give you a manual with the grammatical rules, provide you with lists of nouns, verbs, adjectives and postpositions, explain the application of phonological rules, transliterations of the alphabet, give you a insight in the nominal cases and verb structure, and read with you a text in Kazakh. Nevertheless, without being rude, I bet that even then you are unable to flawlessly produce a poem or even a brief text in Kazakh yourself.

OK, I see your desperation, and I take your analogy (I’m a scholar myself, not a programmer): if someone came to you with the Iliad and explained that he doesn’t know a word of Kazakh but wants all of Homer’s poem, every line, every word, every nuance, expressed in Kazakh with the help of a grammar and a dictionary, you’d reply that this is not how learning languages works. You begin with simple sentences and work your way up. You have shown us several times examples that don’t work, and I have expressed my suspicion that this may be due to using the correspondence module. You weren’t sure whether you need it or not; which is something only you can know. What does this module offer that can’t be accomplished otherwise? If you look at the documentation of the module, you see that the \startletter … \stopletter pair starts an environment within a \starttext … \stoptext context document. When you look at your setup, you will see that you have a \startletter … \stopletter, then a few setups, and then a \starttext … \stoptext document. I’m not a programmer, but I see that this will not work. 

So for some simple rules: when you process an xml buffer (or document), you define xmlsetups for the different xml elements. When you write \xmlprocessbuffer, that’s when these elements will be processed - which means: that’s when your document will be built. You can’t go through your xml buffer/document and then add further text (well you can, but that’s more complicated), so what you have to do is add your text (for the sake of this example: \input knuth) WITHING THESE SETUPS. So let’s start with a simple document that will work:

\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}{contacts|contact|formalname|informalname|prefix|initials|address|city|text|kix|p}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:setups}

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

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

\startxmlsetups xml:contact
	\xmltext{#1}{/address}
	\blank [3*line]
	Subject: your life in \xmltext{#1}{/city}
	\blank [2*line]
	Dear \xmltext{#1}{/prefix} \xmltext{#1}{/formalname},
	\blank [line]
	\input knuth \relax

	Kind regards
	\blank [line]
	X
	\page
\stopxmlsetups

\setuppagenumbering [state=stop]

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

So you see what I’m doing here: I process every simple <contact> element, and I add all the stuff that will go into the letter for every single contact. Start with this document and then find out what you need in addition: a logo, some fancy lines across the letters, a special placement for the address and the subject, etc.? I’m guessing that it would be easier to do this with simple setup commands rather than using the correspondence module, but we have no idea what you need to accomplish. Once you find out what’s missing, you can modify the example and ask additional questions. But, to take your analogy: don’t start with irregular verbs and special cases that will complicate the picture. How is this line

\setuplanguage[nl][date={year, –, mm, –, dd}] % ISO 8601 date

from your original example relevant to your problem? And again: please don’t give me the “I’m not a programmer” response; I’m not a programmer either, but I know that you have to reduce the complexity in problems to find a solution. You’re adding extra complexity.

The way I describe above is the easiest path. There are other approaches, of course: you can combine elements from several xml documents, or you can process the xml data with Lua. All of this may be unnecessary in your case, but nobody will be able to help unless we understand what you need. And to explain this, you will have to start with simple examples, not with a complex document.

Sorry for being somewhat stern, but I’m sure you would give similar advice to your students…

All best

Thomas

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

maillist : ntg-context@ntg.nl / 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	other threads:[~2017-07-30 15:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-30 12:15 r.ermers
2017-07-30 15:38 ` Schmitz Thomas A. [this message]
2017-07-31  8:09   ` r.ermers
     [not found] ` <597DFB2C.60001@gmail.com>
2017-07-31 10:48   ` r.ermers
2017-07-31 15:23     ` Pablo Rodriguez
2017-07-31 16:58       ` r.ermers
2017-07-31 17:23         ` Pablo Rodriguez
2017-07-31 21:57         ` Schmitz Thomas A.
2017-08-01  7:55           ` r.ermers
2017-08-01  8:46             ` Schmitz Thomas A.
2017-08-01 10:15               ` r.ermers
2017-08-01 11:17                 ` Schmitz Thomas A.
2017-08-01 12:04                   ` r.ermers
  -- strict thread matches above, loose matches on Subject: below --
2017-07-28  6:18 r.ermers
2017-07-28  6:18 r.ermers
2017-07-25 11:14 r.ermers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41B71466-27DF-4CCD-9767-15EB58FB1723@uni-bonn.de \
    --to=thomas.schmitz@uni-bonn.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).