Hi Thomas,
My xml processing is normally completely done in lua and that knowledge does
not map one-on-one to the TeX frontend, but the code below is close to what you
want, I think. The main trick is to use the context (no pun intended) to create
two different full \reference commands, with the extra text required as their
\in contents.
I am a unsure about the lpath definitions, these may need fixing or improving.
The “footnote/**/../ref” is my weird way of allowing both
<footnote>..<ref/>
and the deeper embedded
<footnote>..<b>..<ref/>..</b>
as input. There should be a more elegant way to that, but I don’t know how
using TeX syntax. Still, it works.
More problematic is the “../../footnote” lpath. This will only work for the
first case, not for the embedded one. I have no idea whether there is an lpath
for ‘nearest enclosing parent named <footnote>'
Anyway, here is my code.
Best wishes, Taco
\startbuffer[test]
<document>
<p>Here is <ref id="A">Thing A</ref>. It has a reference. It is not inside a
footnote.<footnote id="ftn1">However, <ref id="B">Thing B</ref> is.</footnote>
And so on.</p>
<references>
<referred id="A">Thing A</referred>
<referred id="B">Thing B</referred>
</references>
</document>
\stopbuffer
\startxmlsetups xml:testsetups
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{document|p|ref|references|referred|footnote}{xml:*}
\xmlsetsetup{#1}{footnote/**/../ref}{xml:footnoteref}
\stopxmlsetups
\xmlregistersetup{xml:testsetups}
\startxmlsetups xml:document
\xmlflush {#1}
\stopxmlsetups
\startxmlsetups xml:p
\xmlflush {#1}\par
\stopxmlsetups
\startxmlsetups xml:ref
\reference [\xmlatt {#1} {id}]{}\xmlflush {#1}
\stopxmlsetups
\startxmlsetups xml:footnoteref
\reference [\xmlatt {#1} {id}]{(inside footnote \in[\xmlattribute {#1}
{../../footnote} {id}])}\xmlflush {#1}
\stopxmlsetups
\startxmlsetups xml:footnote
\footnote [\xmlatt {#1} {id}] {\xmlflush {#1}}
\stopxmlsetups
\startxmlsetups xml:references
\page
REFERENCES: \par
\xmlflush {#1}
\stopxmlsetups
\startxmlsetups xml:referred
\xmlflush {#1}: \hfill p. \at [\xmlatt {#1} {id}] \in [\xmlatt {#1}
{id}] \par
\stopxmlsetups
\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
___________________________________________________________________________________