5

I am trying to process JATS XML with ConTeXt. One problem is how I can properly typeset the footnotes since in JATS XML footnote references and footnote content are not at the same location in the source.

\startbuffer[test]
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
                  "JATS-journalpublishing1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
<front>
</front>
<body>
<p>Text.
<xref ref-type="fn" rid="fn1">1</xref>
More Text.
</p>
</body>
<back>
<fn-group>
<fn id="fn1"><p>Footnote content</p></fn>
</fn-group>
</back>
</article>
\stopbuffer

\startxmlsetups xml:test
    \xmlsetsetup{#1}{*}{-}
    \xmlsetsetup{#1}{article|front|body|back|p}{xml:*}
    % Footnotes
    \xmlsetsetup{#1}{fn-group}{xml:*}
    \xmlsetsetup{#1}{fn}{xml:*}
    \xmlsetsetup{#1}{xref[@ref-type='fn']}{xml:footnote}
\stopxmlsetups

\xmlregistersetup{xml:test}

\startxmlsetups xml:footnote
    \xmlfilter
    \footnote{\xmlfirst{test}{fn[@id="\xmlatt{#1}{rid}"]}}
\stopxmlsetups

\startxmlsetups xml:fn-group
    \xmlflush{#1}
\stopxmlsetups

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

% Root
\startxmlsetups xml:article
    \xmlflush{#1}
\stopxmlsetups

% Front
\startxmlsetups xml:front
    \xmlflush{#1}
\stopxmlsetups

% Body
\startxmlsetups xml:body
    \xmlflush{#1}
\stopxmlsetups

% Back
\startxmlsetups xml:back
    \xmlflush{#1}
\stopxmlsetups

% Paragraphs
\startxmlsetups xml:p
    \xmlflush{#1}
\stopxmlsetups

\starttext
\xmlprocessbuffer{test}{test}{}
\stoptext

With this setup the footnotes show up twice, once in the footnotes, but also in the main text. If I change this

\xmlsetsetup{#1}{fn-group}{xml:*}
\xmlsetsetup{#1}{fn}{xml:*}

to

\xmlsetsetup{#1}{fn-group}{}
\xmlsetsetup{#1}{fn}{}

the footnote content disappears in both locations.

In the ConTeXt XML manual (p. 86--87), there is an example of how to achieve this with an lua-based approach. I have managed to adapt this approach to my setting, but I would nevertheless like to understand how to properly use such an lookup based approach.

1 Answer 1

5

You can set fn-group to empty but flush fn:

\startxmlsetups xml:test
    \xmlsetsetup{#1}{*}{-}
    \xmlsetsetup{#1}{article|front|body|back|p}{xml:*}
    % Footnotes
    \xmlsetsetup{#1}{fn-group}{}
    \xmlsetsetup{#1}{fn}{xml:*}
    \xmlsetsetup{#1}{xref[@ref-type='fn']}{xml:footnote}
\stopxmlsetups

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .