arbitrary context commands in xml file
Hi Is there a way to add arbitrary context commands to an xml file without defining an injector first? Best Denis
I mean without breaking the xml of course. Something like an ad hoc injector...
________________________________________
Von: ntg-context
Thanks. But won't that break the xml? I'll need a new element for this right? But what if the schema doesn't allow this?
________________________________________
Von: Wolfgang Schuster
I mean without breaking the xml of course. Something like an ad hoc injector...
\startxmlsetups ... \xmlflushcontext{#1} \stopxmlsetups Wolfgang
Just to provide more information about what I was thinking: You do your typesetting based on an XML doc. Now it is time for the finishing touches. In a tex document you'd add the usual commands to manipulate the layout: \adaptlayout[lines=+1] \testpage[3] \looseness=-1 / \looseness=+1 \blank \setuptolerance etc. Now, of course you can define an injector for these commands, some are predefined, like page, column, blank. But, if my understanding is correct, you'd have to define one for each of the possible parameters. So, you'll need: \startsetups xml:directive:injector:testpagethree \testpage[3] \stopsetups \startsetups xml:directive:injector:testpagefour \testpage[4] \stopsetups etc., and \startsetups xml:directive:injector:addoneline \adaptlayout[lines=+1] \stopsetups \startsetups xml:directive:injector:addtwolines \adaptlayout[lines=+1] \stopsetups Here, I was thinking if something like this could be easier: <?context-directive raw-tex-injector \testpage[4]?> Wolfgang's solutions seems to provide that with different means. If I understand correctly, you'd just map an arbitrary XML element to this setup, and you can then do this: <rawtex> \testpage[4] </rawtex> Correct? If yes, that would be a nice solution, but those elements are probably not allowed if your document needs to be validated against a schema, yet processor instructions will be ignored during validation. Any ideas for alternative approaches? What do you think about a raw-tex injector? (Another possibility would be to use Wolfgang's suggestion, and then to use an XSLT stylesheet to remove those illegal nodes for validation purposes...) Best, Denis
-----Ursprüngliche Nachricht----- Von: ntg-context
Im Auftrag von denis.maier@ub.unibe.ch Gesendet: Freitag, 5. März 2021 16:26 An: wolfgang.schuster.lists@gmail.com; ntg-context@ntg.nl Betreff: Re: [NTG-context] arbitrary context commands in xml file Thanks. But won't that break the xml? I'll need a new element for this right? But what if the schema doesn't allow this?
________________________________________ Von: Wolfgang Schuster
Gesendet: Freitag, 5. März 2021 16:01:25 An: mailing list for ConTeXt users Cc: Maier, Denis Christian (UB) Betreff: Re: [NTG-context] arbitrary context commands in xml file denis.maier@ub.unibe.ch schrieb am 05.03.2021 um 15:53:
I mean without breaking the xml of course. Something like an ad hoc injector...
\startxmlsetups ... \xmlflushcontext{#1} \stopxmlsetups
Wolfgang
__________________________________________________________ _________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg- context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net __________________________________________________________ _________________________
On 3/5/2021 10:27 PM, denis.maier@ub.unibe.ch wrote:
Just to provide more information about what I was thinking: You do your typesetting based on an XML doc. Now it is time for the finishing touches. In a tex document you'd add the usual commands to manipulate the layout: \adaptlayout[lines=+1] \testpage[3] \looseness=-1 / \looseness=+1 \blank \setuptolerance etc.
Now, of course you can define an injector for these commands, some are predefined, like page, column, blank. But, if my understanding is correct, you'd have to define one for each of the possible parameters.
So, you'll need:
\startsetups xml:directive:injector:testpagethree \testpage[3] \stopsetups
\startsetups xml:directive:injector:testpagefour \testpage[4] \stopsetups
etc., and
\startsetups xml:directive:injector:addoneline \adaptlayout[lines=+1] \stopsetups
\startsetups xml:directive:injector:addtwolines \adaptlayout[lines=+1] \stopsetups
Here, I was thinking if something like this could be easier:
<?context-directive raw-tex-injector \testpage[4]?> you can also do this:
<testpage n="4"/> \startxmlsetups xml:testpage \testpage[\xmlatt{#1}{n}] \stopxmlsetup and register that one (as in previous examples) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
-----Ursprüngliche Nachricht----- Von: Hans Hagen
Gesendet: Freitag, 5. März 2021 23:17 An: mailing list for ConTeXt users ; Maier, Denis Christian (UB) ; wolfgang.schuster.lists@gmail.com Betreff: Re: [NTG-context] arbitrary context commands in xml file
[...]
Here, I was thinking if something like this could be easier:
<?context-directive raw-tex-injector \testpage[4]?>
you can also do this:
<testpage n="4"/>
\startxmlsetups xml:testpage \testpage[\xmlatt{#1}{n}] \stopxmlsetup
and register that one (as in previous examples)
Thanks,. That's a good idea, but it will also make the XML invalid. Denis
On Mon, 8 Mar 2021 at 10:21,
-----Ursprüngliche Nachricht----- Von: Hans Hagen
Gesendet: Freitag, 5. März 2021 23:17 An: mailing list for ConTeXt users ; Maier, Denis Christian (UB) ; wolfgang.schuster.lists@gmail.com Betreff: Re: [NTG-context] arbitrary context commands in xml file [...]
Here, I was thinking if something like this could be easier:
<?context-directive raw-tex-injector \testpage[4]?>
you can also do this:
<testpage n="4"/>
\startxmlsetups xml:testpage \testpage[\xmlatt{#1}{n}] \stopxmlsetup
and register that one (as in previous examples)
Thanks,. That's a good idea, but it will also make the XML invalid.
Denis
I'd like to second Denis' request for support for XML processing instructions to execute ConTeXt code, rather than elements which can cause big problems if one is working to a fixed schema. It would be a boon to be able to drop in <?context \whatever{fdfd}?> in an XML source. Duncan
On 3/8/2021 12:48 PM, Duncan Hothersall wrote:
On Mon, 8 Mar 2021 at 10:21,
mailto:denis.maier@ub.unibe.ch> wrote: > -----Ursprüngliche Nachricht----- > Von: Hans Hagen
mailto:j.hagen@xs4all.nl> > Gesendet: Freitag, 5. März 2021 23:17 > An: mailing list for ConTeXt users mailto:ntg-context@ntg.nl>; Maier, Denis > Christian (UB) mailto:denis.maier@ub.unibe.ch>; > wolfgang.schuster.lists@gmail.com mailto:wolfgang.schuster.lists@gmail.com > Betreff: Re: [NTG-context] arbitrary context commands in xml file [...]
> > > > Here, I was thinking if something like this could be easier: > > > > <?context-directive raw-tex-injector \testpage[4]?> > you can also do this: > > <testpage n="4"/> > > \startxmlsetups xml:testpage > \testpage[\xmlatt{#1}{n}] > \stopxmlsetup > > and register that one (as in previous examples)
Thanks,. That's a good idea, but it will also make the XML invalid.
Denis
I'd like to second Denis' request for support for XML processing instructions to execute ConTeXt code, rather than elements which can cause big problems if one is working to a fixed schema. It would be a boon to be able to drop in <?context \whatever{fdfd}?> in an XML source.
one of the things that can already be done ... \def\xmltexdirective#1#2{\doif{#1}{command}{#2}} \xmlinstalldirective{tex}{xmltexdirective} <?context-directive tex command \inframed{xxx} ?> <?context-directive tex command \page ?> (the #2 is something without spaces btu one can work around that) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Mon, 8 Mar 2021 at 12:46, Hans Hagen
I'd like to second Denis' request for support for XML processing instructions to execute ConTeXt code, rather than elements which can cause big problems if one is working to a fixed schema. It would be a boon to be able to drop in <?context \whatever{fdfd}?> in an XML source. one of the things that can already be done ...
\def\xmltexdirective#1#2{\doif{#1}{command}{#2}}
\xmlinstalldirective{tex}{xmltexdirective}
<?context-directive tex command \inframed{xxx} ?> <?context-directive tex command \page ?>
(the #2 is something without spaces btu one can work around that)
Aha. Useful, thanks!
Indeed. That's very useful. Thanks!
Von: ntg-context
I'd like to second Denis' request for support for XML processing instructions to execute ConTeXt code, rather than elements which can cause big problems if one is working to a fixed schema. It would be a boon to be able to drop in <?context \whatever{fdfd}?> in an XML source. one of the things that can already be done ...
\def\xmltexdirective#1#2{\doif{#1}{command}{#2}} \xmlinstalldirective{tex}{xmltexdirective} <?context-directive tex command \inframed{xxx} ?> <?context-directive tex command \page ?> (the #2 is something without spaces btu one can work around that) Aha. Useful, thanks!
participants (4)
-
denis.maier@ub.unibe.ch
-
Duncan Hothersall
-
Hans Hagen
-
Wolfgang Schuster