# [NTG-context] Processing XML: Header and footer, data manipulation

Axel Kielhorn tex at axelkielhorn.de
Mon Apr 22 17:50:44 CEST 2019

> Am 22.04.2019 um 11:40 schrieb Pablo Rodriguez <oinos at gmx.es>:
>
>
>  \startxmlsetups xml:prozess
>     \mainlanguage[de]
>
> If this is hardcoded (I mean, you don’t read it from any XML code), I
> would avoid setting the \mainlanguage here.
>
> And you already set it in lines 82-83:
>
>  \language[de]
>  \mainlanguage[de]
>
> BTW, is there any reason to set both \language and \mainlanguage?
> (\mainlanguage should be enough.)

A leftover from merging two documents.
Once should be sufficient.
I’m not sure if it was a good idea to use german names for the elements.
Using english names and making the language configurable may be the next step.

>> I want to set page headers based on information I get from the XML:
>>
>> \startxmlsetups xml:prozess
>>
>> This works on the first page (when the document has more than one
>> page) but headers and footers are empty on subsequent pages.
>>
>> Something (xmlflush?) overwrites my setup.
>> Any idea how I can fix that?
>
> I have a workaround for that:
>
>  \title{\xmltext{#1}{/pnr} \xmltext{#1}{/pname}}
>
>
>     before=,
>     after=,
>     page=,]
>
>> I want to use xmlconcat here, since there may be more than one docan, but I only get the „, “
>>
>> \startxmlsetups xml:psoutdoc
>> %    \inmargin{\xmltext{#1}{/docan} $\Leftarrow$}  {\bf \xmltext{#1}{/docnr}}\xmlflush{#1}
>>    \inmargin{\xmlconcat{#1}{/docan}{, } $\Leftarrow$}  {\bf \xmltext{#1}{/docnr}}\xmlflush{#1}
>>    \xmlsave{#1}{outfile.xml}
>>    \blank
>> \stopxmlsetups
>
> I would avoid using:
>
>  \startxmlsetups xml:docname
>    \xmlflush{#1}
>  \stopxmlsetups
>
> instead of "\xmltext{#1}{/docname}" in the proper places.

Right, I startet out \xmlflush{}ing everything and turned it into \xmltext later.
I missed this one.

> You need to add to get proper content:
>
>  \startxmlsetups xml:docan
>    \xmlflush{#1}
>  \stopxmlsetups
>
> I would replace docname with docan in both places (xmlsetsetup and its
> proper \starxmlsetups).

Great, it works now.

> BTW, what should be child notes to #1? An special lpath or what?

<docan>\xmltext{#1}{../../pverantwortlich}</docan>
to psindoc

And
<docverantwortlich>\xmltext{#1}{../../pverantwortlich}</docverantwortlich>
to psoutdoc

before writing the ps[in|out]doc to an extra file.

But thinking about it, it may be easier to load a <doclist></doclist> tree from a separate file
and add / edit the doc entries based on the <docnr>.
(<docnr>s are unique.)

This part isn’t even in my head now.

> Just in case it helps,

It did, thanks!
Right now the document does what I wanted to do in ConTeXt.
I’m tempted to write the remaining functions in lua instead of python.

Still a lot to learn ahead.

Greetings Axel