ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: processing xml in mkiv
Date: Sun, 16 Mar 2008 13:00:51 +0100	[thread overview]
Message-ID: <D78D5598-38F5-42D0-B3E5-22806EE3BF08@uni-bonn.de> (raw)
In-Reply-To: <20080316120425.bcb38147.schuster.wolfgang@googlemail.com>


On Mar 16, 2008, at 12:04 PM, Wolfgang Schuster wrote:

> On Sun, 16 Mar 2008 11:29:49 +0100
> "Thomas A. Schmitz" <thomas.schmitz@uni-bonn.de> 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
___________________________________________________________________________________


  reply	other threads:[~2008-03-16 12:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-16 10:29 Thomas A. Schmitz
2008-03-16 11:04 ` Wolfgang Schuster
2008-03-16 12:00   ` Thomas A. Schmitz [this message]
2008-03-16 12:51     ` Wolfgang Schuster
2008-03-16 13:40       ` Thomas A. Schmitz
2008-03-16 13:56         ` Wolfgang Schuster
2008-03-16 17:16         ` Hans Hagen
2008-03-17  6:36           ` Thomas A. Schmitz
2008-03-17 13:04             ` Taco Hoekwater
2008-03-18 15:59               ` Thomas A. Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D78D5598-38F5-42D0-B3E5-22806EE3BF08@uni-bonn.de \
    --to=thomas.schmitz@uni-bonn.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).