[Expat-discuss] Parsing xml files with multiple external entities

Karl Waclawek karl@waclawek.net
Wed Apr 24 07:23:12 2002


> Hi all,
> 
> [Forgive me if this is a stupid question, but I've only recently started
> using expat and I can't find a solution in the archives].
> 
> I have an xml file that references three dtds, like this:
> 
> <!DOCTYPE intervalscript SYSTEM 'intervalscript.dtd' [
>     <!ENTITY % worldupdtd SYSTEM 'worldup.dtd'>
>     %worldupdtd;
>     <!ENTITY % visiondtd SYSTEM 'vision.dtd'>
>     %visiondtd;
> ]>
> 
> When I parse this my program only parses one dtd (worldup.dtd in this case).
> If I move the worldup.dtd entity to within intervalscript.dtd the engine
> parses both, but not a third (it seems happy to process only one entity per
> file).
> 
> Can anyone give me advice about where I'm going wrong?

Which version of Expat did you use?

I had a different experienc, even worse than yours:

In my tests it seemed that Expat ignored External Parameter
Entity declarations in the DTD (internal or external subset).
Meaning, the entity declaration handler is never called.
However, Expat will report the PE reference.

Now, the XML spec says that a PE reference need only be included 
if the XML parser is validating, so, strictly speaking, I could
simply ignore PE references for which no declaration was reported.

Still, I find it strange, that Expat does not report entity
declarations when it reports the associated references.

Is this a bug?

Karl