ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* coupling node name to xmlsetup
@ 2018-09-12 12:15 Hans van der Meer
  2018-09-13 13:30 ` Taco Hoekwater
  0 siblings, 1 reply; 2+ messages in thread
From: Hans van der Meer @ 2018-09-12 12:15 UTC (permalink / raw)
  To: NTG ConTeXt


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

Suppose we have node <example> and want to execute the xmlsetup: mysetups:examplehandler on it. The idea is not to hardcode this but to do it on the fly from <definesetup name=“example”>.

The following \xmlsetup comes into mind:

\startxmlsetups mysetups:definesetup
	\xmlsetsetup{#1}{\xmlatt{#1}{name}}{mysetups:examplehandler}
\stopxmlsetups
\startxmlsetups mysetups:examplehandler
...
\stopxmlsetups

But this is either the wrong call or there is something missing, because on input of <example/> the examplehandler is not invoked.
How to?

dr. Hans van der Meer



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

[-- Attachment #2: Type: text/plain, Size: 492 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] 2+ messages in thread

* Re: coupling node name to xmlsetup
  2018-09-12 12:15 coupling node name to xmlsetup Hans van der Meer
@ 2018-09-13 13:30 ` Taco Hoekwater
  0 siblings, 0 replies; 2+ messages in thread
From: Taco Hoekwater @ 2018-09-13 13:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

I’ll bump this, because the idea sounded intriguing to me as well. 

> On 12 Sep 2018, at 14:15, Hans van der Meer <havdmeer@ziggo.nl> wrote:
> 
> Suppose we have node <example> and want to execute the xmlsetup: mysetups:examplehandler on it. The idea is not to hardcode this but to do it on the fly from <definesetup name=“example”>.
> 
> The following \xmlsetup comes into mind:
> 
> \startxmlsetups mysetups:definesetup
> 	\xmlsetsetup{#1}{\xmlatt{#1}{name}}{mysetups:examplehandler}

I assume that should have been 

  \xmlsetsetup{\xmldocument}{\xmlatt{#1}{name}}{mysetups:examplehandler}

but with that, it does not work either. My MWE looks like this:

\enabletrackers[lxml.*]

\startxmlsetups mysetups:examplehandler
  examplehandler
\stopxmlsetups

\startxmlsetups mysetups:definesetup
  definesetup\par
  \xmlsetsetup{\xmldocument}{\xmlatt{#1}{name}}{mysetups:examplehandler}
\stopxmlsetups

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

\startxmlsetups mysetups:oursetups
  \xmlsetsetup{\xmldocument}{*}{+}
  \xmlsetsetup{\xmldocument}{xml|definesetup}{mysetups:*}
\stopxmlsetups

\xmlregistersetup{mysetups:oursetups}

\starttext
\startbuffer[xml]
<xml>
<definesetup name="example">
   whatever
</definesetup>
<example>
   inputted text
</example>
</xml>
\stopbuffer

\xmlprocessbuffer{main}{xml}{}

\stoptext



___________________________________________________________________________________
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] 2+ messages in thread

end of thread, other threads:[~2018-09-13 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-12 12:15 coupling node name to xmlsetup Hans van der Meer
2018-09-13 13:30 ` Taco Hoekwater

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).