coupling node name to xmlsetup
![](https://secure.gravatar.com/avatar/be49110e195f5eac47c04570251121c1.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
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
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
participants (2)
-
Hans van der Meer
-
Taco Hoekwater