Hi Denis,

Many thanks for your message and for the example you shared.

You are absolutely right to ask why I used\xmlload and targeted extraction in my first attempts. My initial goal was simply to build a small pedagogical demonstration for a French Wikibook on ConTeXt (a chapter on TEI-XML approach with ConTeXt). I therefore started with a more “manual” and imperative style, to make clear what happens at each step and to keep the entry point as simple as possible for beginners.

Your example, which follows the declarative mapping approach provided by ConTeXt’s XML interface, is indeed much closer to what I ultimately need for larger or more realistic TEI samples. It is also more idiomatic ConTeXt and definitely better suited for users who want to structure a whole document rather than extract small pieces of XML.

I’ll therefore integrate your approach in the didactic material, after the minimal introductory example.

Thank you again for pointing me in the right direction !

Best ,
Jean-Pierre


Le 01/12/2025 à 10:29, [email protected] a écrit :

Hi Jean-Pierre,

Why do you use \xmlload etc? Perhaps you could tell us a bit more about your use case?

In any case, I'd use the example in the mkiv-xml as a starting point and adapt that (example below). You can see that this works in a declerative way. You essentially map source nodes to the target document rather than rebuilding the document manually in tex and pulling data in where needed as in your example (obviously, there are situations where you might want to do that, but I don't know if TEI processing is a good use case for that).

Best,

Denis

%%%%%%%% TEI-Example %%%%%%%%%%%%%%%%%%%%%%%

\startxmlsetups xml:TEIsetups

\xmlsetsetup{#1}{*}{-}

\xmlsetsetup{#1}{TEI|text|body}{xml:*}

\xmlsetsetup{#1}{p|persName|placeName|note}{xml:*}

\xmlsetsetup{#1}{div[@type='edition']}{xml:div-edition}

\xmlsetsetup{#1}{div[@type='translation']}{xml:div-translation}

\stopxmlsetups

\xmlregisterdocumentsetup{TEI}{xml:TEIsetups}

\startxmlsetups xml:TEI

    \xmlflush{#1}

\stopxmlsetups

\startxmlsetups xml:text

    \xmlflush{#1}

\stopxmlsetups

\startxmlsetups xml:body

    \xmlflush{#1}

\stopxmlsetups

\startxmlsetups xml:div-edition

\chapter{\xmltext{#1}{head}}

  \xmlflush{#1}

\stopxmlsetups

\startxmlsetups xml:div-translation

\subject{\xmltext{#1}{head}}

  \xmlflush{#1}

\stopxmlsetups

\startxmlsetups xml:p

    \xmlflush{#1}

\stopxmlsetups

\startxmlsetups xml:persName

\sc{\xmlflush{#1}}

\stopxmlsetups

\startxmlsetups xml:placeName

\emph{\xmlflush{#1}}

\stopxmlsetups

\startxmlsetups xml:note

\footnote{\xmlflush{#1}}

\stopxmlsetups

\startbuffer[TEI]

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

<TEI>

  <text>

    <body>

      <div type="edition" xml:lang="la">

<head>Exemplum Ciceronis</head>

        <p>

<persName>Marcus Tullius Cicero</persName>

          in

<placeName>Arpino</placeName>

          natus est.

<note>Simple note.</note>

        </p>

      </div>

      <div type="translation" xml:lang="fr">

<head>Traduction française</head>

<p>Cicéron naquit à Arpinum.</p>

      </div>

    </body>

  </text>

</TEI>

\stopbuffer

\starttext

\xmlprocessbuffer{TEI}{TEI}{}

\stoptext

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

*Von:*Jean-Pierre Delange via ntg-context <[email protected]>
*Gesendet:* Sonntag, 30. November 2025 21:25
*An:* [email protected]
*Cc:* Jean-Pierre Delange <[email protected]>
*Betreff:* [NTG-context] Re: XML/TEI parsing issue in LMTX: lxp.lom not found (small test case)

Hi ConTeXters !

I reply to myself regarding the issue of compiling tex-xml-tei files. ConTeXt was complaining that it could not find the ‘lxp.lom’ module, which is actually a Lua module... The reason was that I was compiling with LMTX and not with MKIV. All I had to do was run the command: context --luatex myfile.tex and the complaint disappeared. I would like to take this opportunity to ask Hans: is it a scientific and demonstrable fact that the implementation of Luatex in ConTeXt-LMTX left out this ‘lpx.lom’?

Thank you very much,

JP

Le 30/11/2025 à 09:00, Jean-Pierre Delange via ntg-context a écrit :

    I fellows (and Hraban) !

    I looked into how to use only the XML embedded by ConTeXt. And I
    found the solution for a simple (and functional) MWE. Now I just
    need to apply the principle to a slightly more complex example.
    Here are the two files used to display the plain text, its
    translation, and the footnote.

    1. the xml file 'cicero-sample-tei.xml' :

    <?xml version="1.0" encoding="UTF-8"?>
    <TEI>
      <text>
        <body>

          <div type="edition" xml:lang=" <xml:lang=>la">
            <head>Exemplum Ciceronis</head>
            <p>
              <persName>Marcus Tullius Cicero</persName>
              in
              <placeName>Arpino</placeName>
              natus est.
              <note>Simple note.</note>
            </p>
          </div>

          <div type="translation" xml:lang=" <xml:lang=>fr">
            <head>Traduction française</head>
            <p>Cicéron naquit à Arpinum.</p>
          </div>

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

    2. The ConTeXt file, cicero-tei-setup.tex

    % cicero-tei-setup.tex

    \setuppapersize[A5]

    \setupbodyfont[latin-modern]

    % Load the TEI xml file

    \xmlload{cicero}{cicero-sample-tei.xml}{}

    \starttext

    % 1. Title of edition (head of the "edition" part)

    \chapter{\xmltext{cicero}{/TEI/text/body/div[@type='edition']/head}}

    % 2. Paragraphe latin, with manual configuration

    %

    % <persName> -> petites capitales

    % <placeName> -> italique

    % <note> -> note de bas de page

    %

    \sc{\xmltext{cicero}{/TEI/text/body/div[@type='edition']/p/persName}}

    \space in

    \em{\xmltext{cicero}{/TEI/text/body/div[@type='edition']/p/placeName}}

    \space natus est.\footnote{%

    \xmltext{cicero}{/TEI/text/body/div[@type='edition']/p/note}%

    }

    \blank[2*big]

    % 3. Translation tiltle

    \subject{\xmltext{cicero}{/TEI/text/body/div[@type='translation']/head}}

    % 4. Translation Paragraph

    \xmltext{cicero}{/TEI/text/body/div[@type='translation']/p}

    \stoptext

    I'm trying to develop some documentation on processing
    multilingual texts with XML-TEI... I hope I'll get somewhere!

    JP

    Le 29/11/2025 à 14:10, Henning Hraban Ramm a écrit :

        Am 29.11.25 um 13:44 schrieb Jean-Pierre Delange via ntg-context:

            local lom = require("lxp.lom")



            |lua error: module'lxp.lom'notfound: no field
            package.preload['lxp.lom'] no file '.../lua/lxp/lom.lua'... |


        When ConTeXt can’t find your lua library, everything else
        makes no sense to share (while I find your project interesting).

        Where is this file? Why do you think ConTeXt should be able to
        find it without a path?

        If it’s within one of the texmf trees, did you run "mtxrun
        --generate"?
        Mayybe try to delete the caches – in case you installed
        ConTeXt (or TeX live) as root/Administrator, there might be a
        conflict with user caches.

        Hraban
        
___________________________________________________________________________________

        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

    
___________________________________________________________________________________
___________________________________________________________________________________
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