Typesetting material containing macro's from inside a xml-node does not give TeX-ed results. How can this be accomplished? ==== Minimal example ConTeXt code: \startxmlsetups xml:testsetups \xmlsetsetup{test}{test}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:test \xmlflush{#1}% same with: \xmltext{#1}{} \stopxmlsetups \setuppapersize[A6][A6] \starttext By \type{\xmlprocessfile{test}{test.xml}{}}:\par \xmlprocessfile{test}{test.xml}{} \blank Directly:\par This must be {\bf bold text}. \stoptext ==== Input: <?xml version="1.0" encoding="UTF-8"?> <test> This must be {\bf bold text}. </test> ==== Output: Hans van der Meer
On 2010-03-17 <11:28:30>, Hans van der Meer wrote:
Typesetting material containing macro's from inside a xml-node does not give TeX-ed results. How can this be accomplished? Hi Hans,
I'm using extra tags with setups because no TeX code seems to be processed directly from the xml file. ---8<-test.xml----------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <test> This must be {\bf bold text}. This is <bf>bold text</bf>. </test> ---8<-------------------------------------------------------------------------- ---8<-test.tex----------------------------------------------------------------- \startxmlsetups xml:testsetups \xmlsetsetup{test}{test|bf}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:bf {\bold \xmlflush{#1}} \stopxmlsetups \startxmlsetups xml:test \xmlflush{#1}% same with: \xmltext{#1}{} \stopxmlsetups \setuppapersize[A6][A6] \starttext By \type{\xmlprocessfile{test}{test.xml}{}}:\par \xmlprocessfile{test}{test.xml}{} \blank Directly:\par This must be {\bf bold text}. \stoptext ---8<-------------------------------------------------------------------------- Like this it works here, Philipp
==== Minimal example ConTeXt code: \startxmlsetups xml:testsetups \xmlsetsetup{test}{test}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:test \xmlflush{#1}% same with: \xmltext{#1}{} \stopxmlsetups \setuppapersize[A6][A6] \starttext By \type{\xmlprocessfile{test}{test.xml}{}}:\par \xmlprocessfile{test}{test.xml}{} \blank Directly:\par This must be {\bf bold text}. \stoptext
==== Input: <?xml version="1.0" encoding="UTF-8"?> <test> This must be {\bf bold text}. </test>
==== Output:
Hans van der Meer
___________________________________________________________________________________ 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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments
On 17 mrt 2010, at 11:49, Philipp Gesang wrote:
On 2010-03-17 <11:28:30>, Hans van der Meer wrote:
Typesetting material containing macro's from inside a xml-node does not give TeX-ed results. How can this be accomplished? Hi Hans,
I'm using extra tags with setups because no TeX code seems to be processed directly from the xml file.
Yes, I know that and already have made a setup for common commands like <b>=\bf, <hr/>=\hairline etc. My point however is: How to avoid the need to rewrite in this manner all ConTeXt macros one needs?
---8<- test .xml----------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <test> This must be {\bf bold text}. This is <bf>bold text</bf>. </test> ---8 < --------------------------------------------------------------------------
Like this it works here,
Hans van der Meer
Am 17.03.10 12:03, schrieb Hans van der Meer:
Yes, I know that and already have made a setup for common commands like <b>=\bf, <hr/>=\hairline etc. My point however is: How to avoid the need to rewrite in this manner all ConTeXt macros one needs? Maybe there is a way to let ConTeXt interpret the CDATA content, at the moment it is printed verbatim.
What you can also do is to write TeX content in a tex element and disable xml parsing. A better way is to minimize your markup and inlcude rules etc. in other elements/environments (e.g. headers, descriptions ...) \startbuffer[test] <?xml version="1.0" encoding="UTF-8"?> <test> <![CDATA[ This must be {\bf bold text}. ]]> This is <bf>bold text</bf>. <tex>This is <bf>bold text</bf>.</tex> </test> \stopbuffer \savebuffer[test][test.xml] \startxmlsetups xml:testsetups \xmlsetsetup{test}{test|bf|tex}{xml:*} \stopxmlsetups \xmlregistersetup{xml:testsetups} \startxmlsetups xml:bf {\bf\xmlflush{#1}} \stopxmlsetups \startxmlsetups xml:test \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:tex \disableXML \xmlflush{#1} \stopxmlsetups \starttext \xmlprocessfile{test}{test.xml}{} \stoptext Wolfgang
On 17-3-2010 12:14, Wolfgang Schuster wrote:
\startxmlsetups xml:tex \disableXML \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:tex \xmlraw{#1}{} \stopxmlsetups ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Strange. First ran the Schuster code and got two bold outputs. Then changing to the Hagen code (xmlraw) the <tex>-enclosed code gives: "This is <bf>bold text</bf>. That code doesn't work where the first did. How come? On 17 mrt 2010, at 13:46, Hans Hagen wrote:
On 17-3-2010 12:14, Wolfgang Schuster wrote:
\startxmlsetups xml:tex \disableXML \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:tex \xmlraw{#1}{} \stopxmlsetups
Hans van der Meer
On 17-3-2010 14:09, Hans van der Meer wrote:
Strange. First ran the Schuster code and got two bold outputs. Then changing to the Hagen code (xmlraw) the <tex>-enclosed code gives: "This is <bf>bold text</bf>. That code doesn't work where the first did. How come?
well, it depends on what you want ... Wolfgangs code disabled xml but not really (\disableXML is a no-op in mkiv xml) the xml file is loaded in memory and the <b>... is therefore no text but a node (with text) so if you want to see what it was when input you need to use \xmlverbatim or \xmlraw Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Took me quite some time to discover: \startxmlsetups xml:common:tex \xmlflushcontext{#1}{} \stopxmlsetups but worthwhile because it seems to do what I wanted. Hans van der Meer On 17 mrt 2010, at 13:46, Hans Hagen wrote:
On 17-3-2010 12:14, Wolfgang Schuster wrote:
\startxmlsetups xml:tex \disableXML \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:tex \xmlraw{#1}{} \stopxmlsetups
On 17-3-2010 22:27, Hans van der Meer wrote:
Took me quite some time to discover:
\startxmlsetups xml:common:tex \xmlflushcontext{#1}{} \stopxmlsetups
but worthwhile because it seems to do what I wanted.
that's indeed a new one (added recently), there's also a filter: \xmlfilter{#1}{/whatever/context()} Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
I do not understand the following. Running the Schuster code exactly as it is, the <tex></tex> enclosure works. If however I incorporate the data from file instead of through \savebuffer, then it doesn't work. What crucial detail am I missing here? Hans van der Meer On 17 mrt 2010, at 12:14, Wolfgang Schuster wrote:
Yes, I know that and already have made a setup for common commands like <b>=\bf, <hr/>=\hairline etc. My point however is: How to avoid the need to rewrite in this manner all ConTeXt macros one needs? Maybe there is a way to let ConTeXt interpret the CDATA content, at
Am 17.03.10 12:03, schrieb Hans van der Meer: the moment it is printed verbatim.
What you can also do is to write TeX content in a tex element and disable xml parsing.
A better way is to minimize your markup and inlcude rules etc. in other elements/environments (e.g. headers, descriptions ...)
\startbuffer[test] <?xml version="1.0" encoding="UTF-8"?> <test> <![CDATA[ This must be {\bf bold text}. ]]> This is <bf>bold text</bf>. <tex>This is <bf>bold text</bf>.</tex> </test> \stopbuffer
\savebuffer[test][test.xml]
\startxmlsetups xml:testsetups \xmlsetsetup{test}{test|bf|tex}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:testsetups}
\startxmlsetups xml:bf {\bf\xmlflush{#1}} \stopxmlsetups
\startxmlsetups xml:test \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:tex \disableXML \xmlflush{#1} \stopxmlsetups
\starttext
\xmlprocessfile{test}{test.xml}{}
\stoptext
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://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Am 17.03.10 14:20, schrieb Hans van der Meer:
I do not understand the following. Running the Schuster code exactly as it is, the <tex></tex> enclosure works. If however I incorporate the data from file instead of through \savebuffer, then it doesn't work. \savebuffer writes the content into the external file test.xml, you never process the buffer content What crucial detail am I missing here? I wonder why you haven't noticed this nonsense in my example
<tex>This is <bf>bold text</bf>.</tex> while you wanted <tex>This is {\bf bold text.}</tex> D’oh ;) Wolfgang
participants (4)
-
Hans Hagen
-
Hans van der Meer
-
Philipp Gesang
-
Wolfgang Schuster