On Mar 16, 2008, at 12:04 PM, Wolfgang Schuster wrote: > On Sun, 16 Mar 2008 11:29:49 +0100 > "Thomas A. Schmitz" <[EMAIL PROTECTED]> wrote: > >> Hi all, >> >> xml processing is about the last part of my ConTeXt stuff where I >> haven't been able to switch to mkiv; I just can't get my head around >> it... 2 questions: >> >> 1. When I try to process a xml-file with my old (mkii) environments, >> the output looks OK, but I always get a first page with the xml >> version declaration >> >> <?xml version="1.0" encoding="utf-8"?> >> >> Is this a bug or a feature? Is there anything I can do to prevent it? > > Can you post a example, I never saw such a effect in my test files.
Hi Wolfgang, OK, here is a minimal example: file test.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE test [ <!ELEMENT document (section)> <!ELEMENT section (#PCDATA)> ]> <document> <section title="First"> <p>This is <quotation>an</quotation> xml file.</p> </section> </document> file testenvironment.tex \usemodule[xtag-ent] \defineXMLenvironment[document] {\starttext} {\stoptext} \defineXMLenvironment[section] {\section{\XMLpar{section}{title}{}}} {} \defineXMLenvironment[quotation] {\quotation\bgroup} {\egroup} When I process with mkii, I get the expected output. Processing with texexec --lua --env=testenvironment test.xml gives me the first line (here it's not an entire page) I described! > > >> 2. I'm really lost with the new xml mechanism. My first problem: In a >> message from September last year, Hans explained that the command to >> process xml files is: >> >>> The regular definitions still work but processing a file is done >>> differently: >>> >>> \xmlprocess{id}{filename}{optional initialization setup} >> >> I used to have environments with which to typeset a bunch of files. >> How can this be ported to the new mechanism, which appears to expect >> a filename? > > \xmlprocess{main}{filename.xml}{} works for me. I tried to translate this into the "new" mechanism and thought it should read like so: \startxmlsetups xml:mysetups \xmlsetsetup{\xmldocument}{text:p|section|quotation}{xml:*} \stopxmlsetups \xmlregistersetup{xml:mysetups} \startxmlsetups xml:p \xmlflush{#1}\endgraf \stopxmlsetups \startxmlsetups xml:quotation \quotation{\xmlflush{#1}} \stopxmlsetups \startxmlsetups xml:section \section{\xmlatt{#1}{section}{title}} \stopxmlsetups \starttext \xmlprocess{main}{test.xml}{} \stoptext But then, I only get "invalid xml file" in the output. > > >> Sorry if these are very basic problems, but I'm probably a bit obtuse >> here. > > You don't have to use new xml mechanism form MkIV, the old code could > be used without problems. The advantage of the new code is direct > access to elements in the tree (you could use xml files as database) > and the option to read from zip files. > > Wolfgang OK, I'll keep that in mind. Thanks for your help, Wolfgang! Thomas ___________________________________________________________________________________ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________