At 09:10 AM 10/8/2001 +0200, Berend de Boer wrote:
>Jaroslav Snajdr <[EMAIL PROTECTED]> writes:
>
> > Hello,
> >
> > I've started playing with XML support in Context and have a couple of
> problems:
> >
> > 1. My XML document is divided into several files. The DOCTYPE
> declaration looks like this:
> >
> > <!DOCTYPE book PUBLIC ...docbook stuff... [
> > <!ENTITY ch1 SYSTEM "chapter1.xml">
> > <!ENTITY ch2 SYSTEM "chapter2.xml">
> > ]>
> > <book>
> > ..
> > &ch1;
> > &ch2;
> > ..
> > </book>
> >
> > How can I process this document in Context? I can define the
> > entities &chx;, but that means to define the mapping to file at two
> > places.
>
>
>I think Hans should give you a call back for ENTITY. There you can do
>your own parsing and define the entities based on the particular
>entity definition.
>
>AFAIK this is not yet possible.
You're right! Say that you have:
\unprotect
\def\@@XMLescape {\@@XML esc}
\def\defineXMLescape[#1]#2{\long\setvalue{\@@XMLescape:#1}{#2}}
\defineXMLescape [--] {\gobbleuntil{-->}}
\defineXMLescape [CDATA] {\skipfirstverbatimlinefalse
\processtaggeddisplayverbatim{]]>}}
\defineXMLescape [\s!default] {\gobbleuntil{>}}
\def\executeXMLescape#1%
{\executeifdefined{\@@XMLescape:#1}{\getvalue{\@@XMLescape:\s!default}}}
\protect
\long\def\xdoXMLelement !#1 % !-- --> or !xyz >
{\endgroup\executeXMLescape{#1}}
Now, given that you have a </hello/> <world/> file, and a ! handler like:
\defineXMLescape [DOCTYPE] {\handleXMLescapeDOCTYPE}
\defineXMLescape [ENTITY] {\handleXMLescapeENTITY}
\def\handleXMLescapeDOCTYPE#1[#2]>%
{#2}
\def\handleXMLescapeENTITY#1 #2 "#3"#4>%
{\doif{#2}{SYSTEM}{\defineXMLentity[#1]{\readfile{#3}{}{}}}}
then:
\defineXMLsingular [test] {WHOW}
\defineXMLsingular [hello] {Hello}
\defineXMLsingular [world] {World}
\startXMLdata
<!DOCTYPE some unreadable crap
[ <!ENTITY wellwell SYSTEM "test.xml"> ]>
test <test/>
<!-- hellup -->
test <test/>
&wellwell;
\stopXMLdata
will do what you want. But i suppose that the DOCTYPE syntax is richer that
this example and i praise myself lucky that i don;t have a copy of the
specs here -)
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | [EMAIL PROTECTED]
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------