Aah yes, how silly of me to forget to add \starttext... \stoptext! Thanks for your help.
Best Wishes
Keith
On 6/5/2018 10:03 PM, Keith McKay wrote:
Dear List,you need to add \starttext ... \stoptext
In my continuing effort to improve my ConTeXt skills I thought I would have a look at XML and ConTeXt. Note: I have no XML skills but, "in for a penny, in for a pound", as they say over here. I started by looking at the very first example on page 5 of "Dealing with XML in ConTeXt mkiv" and straight away hit a problem. There is a typo in the first line of the XML file which I corrected:
<?xml version='1.0' standalone='yes?>
should be
<?xml version="1.0" standalone="yes"?>
However when I ran the file using the tex file it only produced a 3 page pdf with a contents page and 2 title pages and no other text.
Here is the XML file which is the similar to the one on page 5 but with two sections rather than one:
<?xml version="1.0" standalone="yes"?>
<document>
<section>
<title>Some title</title>
<content>
<p>a paragraph of text</p>
<p>another paragraph of text</p>
</content>
</section>
<section>
<title>Another title</title>
<content>
<p>a paragraph of text</p>
<p>another paragraph of text</p>
</content>
</section>
</document>
The TeX file is cut and pasted from pages 5 and 6 of xml-mkiv.pdf:
\startxmlsetups xml:demo:base
\xmlsetsetup{#1}{document|section|p|itemize|item}{xml:demo:*}
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{xml:demo:base}
\startxmlsetups xml:demo:document
\starttitle[title={Contents}]
\placelist[chapter]
\stoptitle
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:demo:section
\startchapter[title=\xmlfirst{#1}{/title}]
\xmlfirst{#1}{/content}
\stopchapter
\stopxmlsetups
\startxmlsetups xml:demo:p
\xmlflush{#1}\endgraf
\stopxmlsetups
\xmlprocessfile{demo}{demo.xml}{}
This seemed such a simple example and I'm a bit perplexed as to why it did not work. Can somebody explain why no paragraphs are showing up? I'm using:
ConTeXt ver: 2018.04.04 00:51 MKIV beta fmt: 2018.6.2 int: english/english
LuaTeX, Version 1.07.0 (TeX Live 2018)
Thanks and Best Wishes
\startbuffer[demo]
<?xml version="1.0" standalone="yes"?>
<document>
<section>
<title>Some title</title>
<content>
<p>a paragraph of text</p>
<p>another paragraph of text</p>
</content>
</section>
<section>
<title>Another title</title>
<content>
<p>a paragraph of text</p>
<p>another paragraph of text</p>
</content>
</section>
</document>
\stopbuffer
\startxmlsetups xml:demo:base
\xmlsetsetup{#1}{document|section|p|itemize|item}{xml:demo:*}
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{xml:demo:base}
\startxmlsetups xml:demo:document
\starttitle[title={Contents}]
\placelist[chapter]
\stoptitle
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:demo:section
\startchapter[title=\xmlfirst{#1}{/title}]
\xmlfirst{#1}{/content}
\stopchapter
\stopxmlsetups
\startxmlsetups xml:demo:p
\xmlflush{#1}\endgraf
\stopxmlsetups
\starttext
\xmlprocessbuffer{demo}{demo}{}
\stoptext
-----------------------------------------------------------------
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
___________________________________________________________________________________