Hi Denis,
Many thanks for your clever remark about |\xmltext| versus |\xmlflush|.
It is a very helpful clarification, and one that deserves to be made
explicit in documentation.
Your point made me realize that, while |\xmltext| is perfectly adequate
for very simple MWEs where XML elements contain only plain text, it can
silently discard structural information as soon as nested elements are
introduced. In other words, it extracts the textual content, but
bypasses the XML processing pipeline.
By contrast, |\xmlflush| preserves the full XML structure and allows
ConTeXt to continue dispatching nested elements through their own setups
(such as |<emph>|, |<hi>|, |<note>|, etc.). This distinction is subtle
but crucial as soon as one moves from a didactic example to a more
realistic TEI use case. Even though our current MWE does not include
nested inline elements, your remark highlights an important conceptual
point about XML processing in ConTeXt, and I will explicitly mention it
in the ConTeXt Garden documentation so that readers do not fall into
this trap later on.
Thank you again for this very precise and illuminating observation.
Best,
JP
Le 12/12/2025 à 22:30, [email protected] a écrit :
Hi Jean-Pierre,
Just a quick note: You’re using \xmltext where I would probably prefer
\xmlflush. With \xmltext you may be loosing elements further down the
tree (not the element content).
Say, the first line of the poem where:
<l>First <emph>light</emph> touches the closed houses,</l>
With \xmltext, you’ll just get the textual content. But with \xmlflush
you can process nested elements as well:
\startxmlsetups xml:original
\language[english]
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:emph
\emph{\xmlflush{#1}}
\stopxmlsetups
Of course, that’s not relevant for your example, but it may be worth
mentioning anyway.
Best,
Denis
*Von:*Jean-Pierre Delange via ntg-context <[email protected]>
*Gesendet:* Freitag, 12. Dezember 2025 21:11
*An:* [email protected]
*Cc:* Jean-Pierre Delange <[email protected]>
*Betreff:* [NTG-context] Re: XML-TEI : \xmlprocessfile: unexpected
character in setup name
Hi Hans !
Many thanks for your help and for the example you shared on the
list. The method of placing the XML directly in a
|\startbuffer...\stopbuffer| and then processing it with
|\xmlprocessbuffer| had completely escaped me—it's a simple trick, but
extremely robust and educational, especially for producing standalone
MWEs. Using your skeleton as a basis, I was able to set up a working
example (XML-TEI poem, original/translation in columns, line-by-line
comments in the form of placeable notes), without any collisions with
tables or footnote stacking. I am pasting the complete source file
|.tex| below, which compiles as is; I will also integrate it as an MWE
in ConTeXt Garden and in a French ConTeXt Wikibook I am working on,
explicitly mentioning your approach.
Thank you again for this elegant and “ConTeXt-proof” solution !
Best regards,
JP
The MWE (1 PDF page) :
\setuppapersize[A4]
\setupbodyfont[Noto Serif,10pt] % Latin Modern (défaut), 10pt % choose
a font
\setupTABLE[frame=off]
\setupTABLE[column][1][width=.1\textwidth]
\setupTABLE[column][2][width=.450\textwidth]
\setupTABLE[column][3][width=.45\textwidth]
% ----------------------------------------------------------
% Pied de page
% ----------------------------------------------------------
\setupfootertexts
[]
[{\tfxx Document composé avec \ConTeXt}]
% ----------------------------------------------------------
% Notes "plaçables" (robustes avec les tableaux)
% ----------------------------------------------------------
\definenote[commnote]
\setupnote[commnote][
rule=off,
paragraph=yes,
inbetween=\quad,
style=\tfxx,
]
% ----------------------------------------------------------
% XML dans un buffer (méthode Hans) — 16 vers + commentaire
% ----------------------------------------------------------
\startbuffer[poem]
<?xml version="1.0" encoding="UTF-8"?>
<TEI>
<text>
<body>
<lg type="stanza">
<lg type="orig">
<l>First light touches the closed houses,</l>
<l>and the street breathes a pale memory.</l>
<l>I hear the fountain count its coins,</l>
<l>while sparrows edit yesterday’s crumbs.</l>
<l>The baker lifts a shutter like a veil,</l>
<l>and flour rises, a brief white weather.</l>
<l>At the corner, a newspaper opens,</l>
<l>its headlines folded like tired wings.</l>
<l>I write your name, then cross it out,</l>
<l>the paper keeps the pressure, not the meaning.</l>
<l>Between two words a well appears,</l>
<l>and echoes practice someone else’s voice.</l>
<l>A tram arrives; its doors hesitate,</l>
<l>as if choosing which century to enter.</l>
<l>In my pocket, a key warms slowly,</l>
<l>metal remembering the shape of home.</l>
</lg>
<lg type="trans">
<l>La première lumière effleure les maisons closes,</l>
<l>et la rue respire une mémoire pâle.</l>
<l>J’entends la fontaine compter ses pièces,</l>
<l>tandis que les moineaux corrigent les miettes d’hier.</l>
<l>Le boulanger relève un volet comme un voile,</l>
<l>et la farine monte, brève météo blanche.</l>
<l>Au coin, un journal s’ouvre,</l>
<l>ses gros titres pliés comme des ailes lassées.</l>
<l>J’écris ton nom, puis je le rature,</l>
<l>le papier garde la pression, pas le sens.</l>
<l>Entre deux mots, un puits apparaît,</l>
<l>et les échos répètent la voix d’un autre.</l>
<l>Un tram arrive ; ses portes hésitent,</l>
<l>comme si elles choisissaient le siècle où entrer.</l>
<l>Dans ma poche, une clé se réchauffe lentement,</l>
<l>le métal se souvient de la forme du foyer.</l>
</lg>
<lg type="comm">
<l>light] atmospheric motif; establishes the scene.</l>
<l>memory] semantic key recurring across the poem.</l>
<l>fountain] auditory image; introduces counting/metre.</l>
<l>edit] meta-textual verb; aligns with “variants” later.</l>
<l>shutter/veil] unveiling metaphor; morning as revelation.</l>
<l>white weather] synesthetic image; flour as climate.</l>
<l>newspaper] public voice entering the private walk.</l>
<l>headlines] folded wings; fatigue of news cycles.</l>
<l>name] inscription + erasure; motif of revision.</l>
<l>pressure/meaning] material trace vs semantic loss.</l>
<l>well] gap between words; abyss of interpretation.</l>
<l>someone else] polyphony; speaker displaced.</l>
<l>tram] modern intrusion; tests punctuation in table.</l>
<l>century] controlled anachronism; time as choice.</l>
<l>key] pocket object; memory by touch/heat.</l>
<l>home] “shape” as form; stable equivalence in translation.</l>
</lg>
</lg>
</body>
</text>
</TEI>
\stopbuffer
% ----------------------------------------------------------
% Setups XML (structure Hans)
% ----------------------------------------------------------
\startxmlsetups xml:main
\xmlsetsetup{#1}{*}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:main}
\startxmlsetups xml:TEI
\xmlcommand{#1}{text/body/lg[@type='stanza']}{xml:stanza}
\stopxmlsetups
\startxmlsetups xml:original
\language[english]
\xmltext{#1}
\stopxmlsetups
\startxmlsetups xml:translation
\language[french]
\xmltext{#1}
\stopxmlsetups
% commentaire -> note "plaçable"
\startxmlsetups xml:comment
\commnote{\xmltext{#1}}
\stopxmlsetups
\startxmlsetups xml:stanza
\bTABLE
\bTR
\bTH line \eTH
\bTH original \eTH
\bTH translation \eTH
\eTR
\dorecurse{\xmlcount{#1}{./lg[@type='orig']/l}}{%
\bTR
\bTD ##1 \eTD
\bTD
\xmlcommand{#1}{./lg[@type='orig']/l[##1]}{xml:original}
\xmlcommand{#1}{./lg[@type='comm']/l[##1]}{xml:comment}
\eTD
\bTD
\xmlcommand{#1}{./lg[@type='trans']/l[##1]}{xml:translation}
\eTD
\eTR
}
\eTABLE
\stopxmlsetups
\starttext
\centerline{\bfb Poème TEI-XML : original, traduction, notes “plaçables”}
\blank[big]
{\em
Objectif : montrer une méthode robuste (inspirée de Hans Hagen) pour
afficher un poème encodé en XML-TEI
en trois colonnes (n° du vers, original, traduction) tout en attachant
un commentaire ligne à ligne sous forme de notes,
placées à un endroit choisi (ici : après le tableau), afin d’éviter
les collisions “tableau + footnotes”. On remarquera les commentaires
en anglais placés dans la cellule concernant le texte original.}
\blank[medium]
\centerline{\sc — Procédure (résumé technique) —}
\starttyping
1) XML intégré dans un buffer (\startbuffer...\stopbuffer)
2) Boucle sur le nombre de vers : \dorecurse{\xmlcount{#1}, etc.
3) Extraction des lignes via XPath : orig/l[i], trans/l[i], comm/l[i]
4) Commentaires collectés avec \commnote{\xmltext{#1}}, puis rendus
par \placenotes[commnote]
\stoptyping
\blank[big]
\xmlprocessbuffer{main}{poem}{}
\blank[big]
% Notes en deux colonnes pour limiter les débordements
\startcolumns[n=2,balance=yes]
\placenotes[commnote]
\stopcolumns
\stoptext
Le 12/12/2025 à 10:01, Hans Hagen via ntg-context a écrit :
On 12/11/2025 9:01 PM, Jean-Pierre Delange via ntg-context wrote:
\startxmlsetups xml:comm
\xmlfilter{#1}{./l}{\footnote{\xmltext{##1}}}
\stopxmlsetups
you have a double # here
I attached a solution.
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl
<http://www.pragma-ade.nl> | www.pragma-pod.nl
<http://www.pragma-pod.nl>
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to
the Wiki!
maillist :[email protected]
/https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage :https://www.pragma-ade.nl /https://context.aanhet.net (mirror)
archive :https://github.com/contextgarden/context
wiki :https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________