ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* arbitrary context commands in xml file
@ 2021-03-05 14:39 denis.maier
  2021-03-05 14:53 ` denis.maier
  0 siblings, 1 reply; 11+ messages in thread
From: denis.maier @ 2021-03-05 14:39 UTC (permalink / raw)
  To: ntg-context

Hi
Is there a way to add arbitrary context commands to an xml file without defining an injector first?
Best
Denis
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-05 14:39 arbitrary context commands in xml file denis.maier
@ 2021-03-05 14:53 ` denis.maier
  2021-03-05 15:01   ` Wolfgang Schuster
  0 siblings, 1 reply; 11+ messages in thread
From: denis.maier @ 2021-03-05 14:53 UTC (permalink / raw)
  To: ntg-context

I mean without breaking the xml of course. Something like an ad hoc injector...



________________________________________
Von: ntg-context <ntg-context-bounces@ntg.nl> im Auftrag von denis.maier@ub.unibe.ch <denis.maier@ub.unibe.ch>
Gesendet: Freitag, 5. März 2021 15:39:53
An: ntg-context@ntg.nl
Betreff: [NTG-context] 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
___________________________________________________________________________________
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
___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-05 14:53 ` denis.maier
@ 2021-03-05 15:01   ` Wolfgang Schuster
  2021-03-05 15:26     ` denis.maier
  0 siblings, 1 reply; 11+ messages in thread
From: Wolfgang Schuster @ 2021-03-05 15:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-05 15:01   ` Wolfgang Schuster
@ 2021-03-05 15:26     ` denis.maier
  2021-03-05 21:27       ` denis.maier
  0 siblings, 1 reply; 11+ messages in thread
From: denis.maier @ 2021-03-05 15:26 UTC (permalink / raw)
  To: wolfgang.schuster.lists, 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 <wolfgang.schuster.lists@gmail.com>
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-05 15:26     ` denis.maier
@ 2021-03-05 21:27       ` denis.maier
  2021-03-05 22:17         ` Hans Hagen
  0 siblings, 1 reply; 11+ messages in thread
From: denis.maier @ 2021-03-05 21:27 UTC (permalink / raw)
  To: ntg-context, wolfgang.schuster.lists

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 <ntg-context-bounces@ntg.nl> 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 <wolfgang.schuster.lists@gmail.com>
> 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
> __________________________________________________________
> _________________________
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-05 21:27       ` denis.maier
@ 2021-03-05 22:17         ` Hans Hagen
  2021-03-08 10:20           ` denis.maier
  0 siblings, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2021-03-05 22:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users, denis.maier, wolfgang.schuster.lists

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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-05 22:17         ` Hans Hagen
@ 2021-03-08 10:20           ` denis.maier
  2021-03-08 11:48             ` Duncan Hothersall
  0 siblings, 1 reply; 11+ messages in thread
From: denis.maier @ 2021-03-08 10:20 UTC (permalink / raw)
  To: j.hagen, ntg-context, wolfgang.schuster.lists

> -----Ursprüngliche Nachricht-----
> Von: Hans Hagen <j.hagen@xs4all.nl>
> Gesendet: Freitag, 5. März 2021 23:17
> An: mailing list for ConTeXt users <ntg-context@ntg.nl>; Maier, Denis
> Christian (UB) <denis.maier@ub.unibe.ch>;
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-08 10:20           ` denis.maier
@ 2021-03-08 11:48             ` Duncan Hothersall
  2021-03-08 12:46               ` Hans Hagen
  0 siblings, 1 reply; 11+ messages in thread
From: Duncan Hothersall @ 2021-03-08 11:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1168 bytes --]

On Mon, 8 Mar 2021 at 10:21, <denis.maier@ub.unibe.ch> wrote:

> > -----Ursprüngliche Nachricht-----
> > Von: Hans Hagen <j.hagen@xs4all.nl>
> > Gesendet: Freitag, 5. März 2021 23:17
> > An: mailing list for ConTeXt users <ntg-context@ntg.nl>; Maier, Denis
> > Christian (UB) <denis.maier@ub.unibe.ch>;
> > 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

[-- Attachment #1.2: Type: text/html, Size: 2175 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-08 11:48             ` Duncan Hothersall
@ 2021-03-08 12:46               ` Hans Hagen
  2021-03-08 13:05                 ` Duncan Hothersall
  0 siblings, 1 reply; 11+ messages in thread
From: Hans Hagen @ 2021-03-08 12:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Duncan Hothersall

On 3/8/2021 12:48 PM, Duncan Hothersall wrote:
> 
> 
> On Mon, 8 Mar 2021 at 10:21, <denis.maier@ub.unibe.ch 
> <mailto:denis.maier@ub.unibe.ch>> wrote:
> 
>      > -----Ursprüngliche Nachricht-----
>      > Von: Hans Hagen <j.hagen@xs4all.nl <mailto:j.hagen@xs4all.nl>>
>      > Gesendet: Freitag, 5. März 2021 23:17
>      > An: mailing list for ConTeXt users <ntg-context@ntg.nl
>     <mailto:ntg-context@ntg.nl>>; Maier, Denis
>      > Christian (UB) <denis.maier@ub.unibe.ch
>     <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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-08 12:46               ` Hans Hagen
@ 2021-03-08 13:05                 ` Duncan Hothersall
  2021-03-08 13:39                   ` denis.maier
  0 siblings, 1 reply; 11+ messages in thread
From: Duncan Hothersall @ 2021-03-08 13:05 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 719 bytes --]

On Mon, 8 Mar 2021 at 12:46, Hans Hagen <j.hagen@xs4all.nl> wrote:

> > 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!

[-- Attachment #1.2: Type: text/html, Size: 1140 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: arbitrary context commands in xml file
  2021-03-08 13:05                 ` Duncan Hothersall
@ 2021-03-08 13:39                   ` denis.maier
  0 siblings, 0 replies; 11+ messages in thread
From: denis.maier @ 2021-03-08 13:39 UTC (permalink / raw)
  To: ntg-context, j.hagen


[-- Attachment #1.1: Type: text/plain, Size: 1058 bytes --]

Indeed. That's very useful. Thanks!

Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Duncan Hothersall
Gesendet: Montag, 8. März 2021 14:06
An: Hans Hagen <j.hagen@xs4all.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Betreff: Re: [NTG-context] arbitrary context commands in xml file



On Mon, 8 Mar 2021 at 12:46, Hans Hagen <j.hagen@xs4all.nl<mailto:j.hagen@xs4all.nl>> wrote:
> 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!

[-- Attachment #1.2: Type: text/html, Size: 3575 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-03-08 13:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 14:39 arbitrary context commands in xml file denis.maier
2021-03-05 14:53 ` denis.maier
2021-03-05 15:01   ` Wolfgang Schuster
2021-03-05 15:26     ` denis.maier
2021-03-05 21:27       ` denis.maier
2021-03-05 22:17         ` Hans Hagen
2021-03-08 10:20           ` denis.maier
2021-03-08 11:48             ` Duncan Hothersall
2021-03-08 12:46               ` Hans Hagen
2021-03-08 13:05                 ` Duncan Hothersall
2021-03-08 13:39                   ` denis.maier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).