[XML-SIG] [ Newbie ] Parsing XML with an external DTD
Fred L. Drake, Jr.
fdrake@acm.org
Mon, 5 Nov 2001 12:28:53 -0500
Alexandre Fayolle writes:
> I guess you could wrap your document into another one using an entity
> (untested) :
Sorry, not quite! Aside from the typographic error in the XML
declaration (missing "?" at end), there's the little matter that the
document element must start & end in the document entity; it can't be
included through an entity reference.
I think you can do this in SGML, but not in XML.
You can't even just concatenate a new prolog with the document if
the document contains an XML declaration, because the second XML
declaration is a well-formedness error.
In practice, what you probably want to do is check for the XML
declaration; if present, provide the declaration to the parser, then
the DOCTYPE declaration, then the rest of the input document. How to
do this depends on the parser interface you're using.
> --------------8<--------------------------------
> <?xml version='1.0' standalone='no'>
> <!DOCTYPE MONDOC SYSTEM "dtd-uri"
> [<!ENTITY core SYSTEM "mondoc.xml">]
> >
> &core;
> --------------8<--------------------------------
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation