[NTG-context] redefining xmlsetups inside a XML document

mf massifr at fastwebnet.it
Tue Mar 22 15:23:37 CET 2022

I found the solution I was looking for. The command to run is still

context --environment=nested-xmlsetup.tex --forcexml nested-xmlsetup.xhtml

In the <script> element there's some tex code, which redefines the 
xmlsetups for <p> and <i> elements, coloring the first ones in red and 
the second ones in blue.

The key command is


where \xmldocument instead of #1 applies the myHtml:* setups to the 
whole XHTML document and not only to the <script> element identified by #1.

I tried also this, to prevent redefining the setups of <html>, <head>, 
<script> elements:


but it doesn't work, since \xmldocument seems to be the actual document 
instead of an id pointing to its root element.


Il 10/03/22 17:52, Hans Hagen ha scritto:
> On 3/10/2022 4:59 PM, mf via ntg-context wrote:
>> Hello,
>> I'm trying to add new templates (xmlsetups) from the XML document itself.
>> See the attached MWE.
>> - the XML document is a simple XHTML file
>> - in the "head" element there's a "script" element with the "type" 
>> attribute set to "text/vnd.context", whose contents are then passed to 
>> \xmlcontext
>> - the "body" element has a "data-xmlsetups" attribute whose value 
>> should tell which xmlsetups is to be applied on the body contents 
>> (it's defined in the "script" element above)
>> If it worked, the resulting PDF should show the body element, followed 
>> by a "Hello world!" paragraph written in red.
>> But it does not work, because there's something I'm missing in the 
>> redefinition and application of xmlsetups.
>> To try the MWE, type:
>> context --environment=nested-xmlsetup.tex --forcexml 
>> nested-xmlsetup.xhtml
>      <script type="text/vnd.context">
>        \startxmlsetups myHtml
>         \xmlsetsetup{#1}{p}{myHtml:p}
>         % you're missing this
>         \xmlsetup{#1}{xml:process}
>         % which is
>         %  \xmlregistereddocumentsetups{#1}{#1}
>         %  \xmlmain{#1}
>        \stopxmlsetups
>        \startxmlsetups myHtml:p
>           \dontleavehmode\red\xmlflush{#1}\par
>        \stopxmlsetups
>      </script>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nested-xmlsetup.xhtml
Type: application/xhtml+xml
Size: 575 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220322/c1e27014/attachment.xhtml>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nested-xmlsetup.tex
Type: text/x-tex
Size: 863 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220322/c1e27014/attachment.tex>

More information about the ntg-context mailing list