Hi Denis,

I am responding once again to clarify the issue encountered yesterday. What appeared to be a ConTeXt “crash” while processing a simple TEI poem (original + translation + commentary), suggested an undefined control sequence in `\xmlfilter`, and the job has terminated with a fatal return code. At first, I has suspected a local installation problem or an incompatibility, or whatever, but after isolating the problem, I realized that it was entirely on my end: *two conflicting XML configurations were capturing the same |<l>| nodes*, producing overlapping routings and, ultimately, an invalid argument had has passed to TeX.

Once I removed all redundant fallbacks and rewrote the routing logic in the cleanest way possible—one dedicated configuration per structural role (|xml:orig|, |xml:trans|, |xml:comm|) and a single unambiguous fallback—everything worked perfectly.

I am attaching *a minimal TEI file* (|poem-tei-demo.xml|) and *a minimal ConTeXt file* (|mwe-xmltei-basic.tex|) that illustrate the working model:

 * |<lg type="stanza">| contains three child blocks (|orig|, |trans|,
   |comm|);
 * the first two are displayed in two columns;
 * the third produces footnotes via a simple filter;
 * each structural role has exactly one configuration, with no
   ambiguous overlap.

This very small pair of files seems to be the most reliable and educational MWE I have been able to extract from my testings. It also avoids the kind of accidental recursion that can occur when mixing global fallback solutions and sub-tree-specific configurations.

Unless you see anything incorrect or misleading in this approach, I would be happy to contribute this template to *ConTeXt Garden* as an introductory example of TEI-based parallel texts. This is a common use case in poetic studies, and having a clean, minimalist template could save newcomers a lot of detours.

There are still things to be done, such as displaying lemmatization in a dedicated footnote for the critical apparatus.

Thank you again for your time and for all your kind attention, which makes this type of editorial work possible.

Best regards,

JP

A — _The XML file_ :/ poem-tei-demo.xml/

<?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>
        </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>
        </lg>
        <lg type="comm">
          <l>light] atmospheric motif in the poem.</l>
          <l>memory] semantic key recurring in several stanzas.</l>
        </lg>
      </lg>

    </body>
  </text>
</TEI>
*
*

B — /mwe-xmltei-basic.tex/

% Minimal TEI → ConTeXt example: original / translation + notes

\setuppapersize[A4]
\mainlanguage[en]
\setupbodyfont[modern,11pt]

% Table: two columns, no frame
\setupTABLE[frame=off]
\setupTABLE[column][1][width=.48\textwidth]
\setupTABLE[column][2][width=.48\textwidth]

% ------------------------------
% XML routing
% ------------------------------

\startxmlsetups xml:main
  \xmlsetsetup{#1}{*}{xml:all}
  \xmlsetsetup{#1}{lg[@type='stanza']}{xml:stanza}
  \xmlsetsetup{#1}{lg[@type='orig']}{xml:orig}
  \xmlsetsetup{#1}{lg[@type='trans']}{xml:trans}
  \xmlsetsetup{#1}{lg[@type='comm']}{xml:comm}
  \xmlsetsetup{#1}{l}{xml:l}
  \xmlflush{#1}
\stopxmlsetups

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

% ------------------------------
% Stanza = table row
% ------------------------------

\startxmlsetups xml:stanza
  \bTABLE
    \bTR
      \xmlfilter{#1}{./lg[@type='orig']}{\xmlflush{#1}}
      \xmlfilter{#1}{./lg[@type='trans']}{\xmlflush{#1}}
      % Commentary processed separately (notes only)
      \xmlfilter{#1}{./lg[@type='comm']}{\xmlflush{#1}}
    \eTR
  \eTABLE
\stopxmlsetups

% ------------------------------
% Original
% ------------------------------

\startxmlsetups xml:orig
  \bTD
    {\bf Original}\par
    \xmlflush{#1}
  \eTD
\stopxmlsetups

% ------------------------------
% Translation
% ------------------------------

\startxmlsetups xml:trans
  \bTD
    {\bf Translation}\par
    \xmlflush{#1}
  \eTD
\stopxmlsetups

% ------------------------------
% Commentary → footnotes
% ------------------------------

\startxmlsetups xml:comm
  \xmlfilter{#1}{./l}{\footnote{\xmltext{##1}}}
\stopxmlsetups

% ------------------------------
% Leaf nodes
% ------------------------------

\startxmlsetups xml:l
  \xmltext{#1}\par
\stopxmlsetups

% ------------------------------
% Document
% ------------------------------

\starttext
\xmlprocessfile{main}{poem-tei-demo.xml}{xml:main}
\stoptext


Le 11/12/2025 à 13:18, [email protected] a écrit :

Sorry, I saved the xml with a wrong name. Now, it works as expected.

Pdf looks like this;

http://www.tei-c.org/ns/1.0

<TEI xmlns=http://www.tei-c.org/ns/1.0> <text> <body> <lg type="stanza"> <lg

type="orig"> <l>Sometimes I hear the distant call</l> <l n="2">Of nights I thought

would never fade</l> </lg> <lg type="trans"> <l>Parfois j’entends un appel loin­

tain</l> <l n="2">Des nuits que je croyais éternelles</l> </lg> <lg type="comm">

<l>Commentary for line 1</l> <l>Commentary for line 2</l> </lg> </lg> </body>

</text> </TEI>/TEI/text/body

*Von:*[email protected] <[email protected]>
*Gesendet:* Donnerstag, 11. Dezember 2025 13:16
*An:* 'mailing list for ConTeXt users' <[email protected]>
*Cc:* 'Jean-Pierre Delange' <[email protected]>
*Betreff:* AW: [NTG-context] Re: XML-TEI : \xmlprocessfile: unexpected character in setup name

I cannot reproduce your error. Instead I’m gettting a pdf with <error>empty xml file</error>/TEI/text/body

*Von:*Jean-Pierre Delange via ntg-context <[email protected]>
*Gesendet:* Mittwoch, 10. Dezember 2025 22:32
*An:* [email protected]
*Cc:* Jean-Pierre Delange <[email protected]>
*Betreff:* [NTG-context] Re: XML-TEI : \xmlprocessfile: unexpected character in setup name

Just a quick correction: the coding mistake in my email

|\xxmlsetsetup{|main|}{*}{tei:all}|

(with two initial x)

is not present in my actual source file. It was introduced only in the email draft.
The original code uses the correct form:

|\xmlsetsetup{|main|}{*}{tei:all}|

So the issue I am facing is /not/ caused by that typo !

Le 10/12/2025 à 22:24, Jean-Pierre Delange via ntg-context a écrit :

    Hi fellows !

    I am returning to you with some XML-TEI issues. I am trying to
    produce a MWE that shows how to handle the literary analysis of
    versification and how to typeset the results properly. To reach
    this goal, I turned to the XML-TEI approach, but I have
    encountered an issue ...Then, this MWE is now a M(N)WE ...

    • Goal: produce a PDF from a TEI-XML source containing
    – original poem
    – translation
    – commentary
    – notes (<note>)
    – apparatus (<app><lem><rdg>)

    • Desired layout in ConTeXt:
    – original text with line numbers
    – translation in parallel
    – commentary in a third column
    – proper rendering of notes and apparatus

    • Reason for using TEI:
    – separation between content and layout
    – reuse of the same TEI source for different typesettings
    – scalable workflow for wider scholarly editions

    • TEI structure (poem.xml):
    – <lg type="orig">, <lg type="trans">, <lg type="comm">
    – <l> elements for individual lines
    – optional <note> and <app><lem><rdg> elements
    – valid XML and valid TEI namespace declaration

    Minimal TEI file:

    <?xml version="1.0"|encoding=|"UTF-8"|?>|

    <TEI||xmlns|=|"http://www.tei-c.org/ns/1.0"; <http://www.tei-c.org/ns/1.0>|>|

    ||<text|>|

    ||<body|>|

    ||<lg||type|=|"stanza"|>|

    ||<lg||type|=|"orig"|>|

    ||<l|>Sometimes I hear the distant call|</l|>|

    ||<l||n|=|"2"|>Of nights I thought would never fade|</l|>|

    ||</lg|>|

    ||<lg||type|=|"trans"|>|

    ||<l|>Parfois j’entends un appel lointain|</l|>|

    ||<l||n|=|"2"|>Des nuits que je croyais éternelles|</l|>|

    ||</lg|>|

    ||<lg||type|=|"comm"|>|

    ||<l|>Commentary for line 1|</l|>|

    ||<l|>Commentary for line 2|</l|>|

    ||</lg|>|

    ||</lg|>|

    ||</body|>|

    ||</text|>|

    </TEI|>|

    • Minimal ConTeXt debugging file:
    – declares the TEI namespace
    – assigns all elements to a debug setup
    – defines an entry setup for starting the XML traversal
    – calls \xmlprocessfile

    %mwe-xmltei-debug.tex

    |\setuppapersize|[A4]||

    |\setupbodyfont|[modern,11pt]||

    ||

    |\xmlnamespace{tei}{http://www.tei-c.org/ns/|1.0|}|

    ||

    |\xxmlsetsetup{|main|}{*}{tei:all}|

    ||

    |\startxmlsetups tei:all|

    |  \type{NODE: \xmlname{|#1|} -- |TEXT|: \xmltext{|#1|}}|

    |\stopxmlsetups|

    ||

    |\xmlsetsetup{|main|}{/}{tei:start}|

    ||

    |\startxmlsetups tei:start|

    |  \xmlflush{|main|}{/TEI/|text|/|body|}|

    |\stopxmlsetups|

    ||

    |\starttext|

    |\xmlprocessfile{|main|}{poem|.xml|}{tei:start}|

    |\stoptext|

    • Expected result:
    – the PDF should list TEI nodes (NODE: TEI, NODE: lg, NODE: l, etc.)
    – confirms that namespace and setup dispatching work correctly

    • Actual problem:
    – ConTeXt aborts with the TeX error “You can't use the letter
    U+0041 A in horizontal mode”
    – this happens before any TEI node is processed
    – the setup name appears internally as something like “\18>:tei:start”
    – this suggests that the setup identifier is not read as a normal
    control sequence at runtime

    • Technical implication:
    – the entry setup cannot be resolved normally by the XML processor
    – the dispatch never reaches the TEI tree
    – ConTeXt attempts to execute a malformed control sequence and aborts

    Any insights into why the setup name is degraded at runtime, or
    how to stabilise the entry point for XML processing in this
    context, would be warmly welcome (as I've struggled hours on this
    issue !).

    Best regards,

    JP

    
___________________________________________________________________________________

    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
___________________________________________________________________________________

Reply via email to