> On 17. Aug 2025, at 18:39, Thomas A. Schmitz <[email protected]>
> wrote:
>
>
>> On 17. Aug 2025, at 17:52, Hans Hagen via ntg-context <[email protected]>
>> wrote:
>>
>> I assume you checked
>>
>> \xmlcommand
>> \xmlfilter
>>
>> Hans
>
> I checked with lxml.verbatim (lxml.id (note)), and the xml node is as I would
> expect it to be. (I’m at the Lua end). It just gets serialized instead of
> processed…
>
> All best
>
> Thomas
I managed to build a small example…
Here is content of file test.xml:
<chapter>
<chaptertitle>Chapter 1</chaptertitle>
<p>Text <emph>italics</emph>.<note xml:id="note_1">This is
<emph>note</emph> 1.</note></p>
</chapter>
And here is the main test file (colors and hairlines are just for debugging):
\startbuffer[test]
<document>
<include href="test.xml"/>
</document>
\stopbuffer
\startxmlsetups xml:testsetups
\xmlsetsetup{main}{*}{-}
\xmlsetsetup{main}{document|chapter|chaptertitle|note|emph|p}{xml:*}
\stopxmlsetups
\xmlregistersetup{xml:testsetups}
\startxmlsetups xml:document
\xmlfunction {#1} {document}
\stopxmlsetups
\startxmlsetups xml:emph
{\em \xmlflush {#1}}
\stopxmlsetups
\startxmlsetups xml:note:typeset
{\bf \xmlflush {#1}}
\stopxmlsetups
\startluacode
function xml.functions.document (t)
current_file = xml.attribute (t, "/include", "href", "X")
for e in xml.collected (xml.load (current_file), "chapter") do
ch_title = xml.text (lxml.id (e), "/chaptertitle")
context.startchapter { title=ch_title}
for note in xml.collected (lxml.id (e), "/**/note") do
note_ref = xml.attribute (lxml.id (note), "/",
"xml:id", "Y")
note_text = xml.first (lxml.id (note), "/")
context (note_ref)
context (" : ")
context.par ()
context.startcolor { "blue" }
lxml.verbatim (lxml.id (note))
context.par ()
lxml.verbatim (lxml.id (note_text))
context.hairline ()
context.stopcolor ()
context.startcolor { "red" }
lxml.flush (lxml.id (note))
context.par ()
lxml.flush (lxml.id (note_text))
context.hairline ()
context.stopcolor ()
context.startcolor { "green" }
xml.sprint (lxml.id (note))
context.par ()
xml.sprint (lxml.id (note_text))
context.hairline ()
context.stopcolor ()
context.startcolor { "orange" }
xml.cprint (lxml.id (note))
context.par ()
xml.cprint (lxml.id (note_text))
context.hairline ()
context.stopcolor ()
context.startcolor { "yellow" }
lxml.command (lxml.id (note), ".", "xml:note:typeset")
context.par ()
lxml.command (lxml.id (note_text), ".",
"xml:note:typeset")
context.hairline ()
context.stopcolor ()
end
context.stopchapter ()
end
end
\stopluacode
\setupbodyfont [times,12pt]
\starttext
\xmlprocessbuffer{main}{test}{}
\stoptext
___________________________________________________________________________________
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
___________________________________________________________________________________