external parameter entity references in XML - possible eXpat bug

David Madore

Usenet Archive
Joined
Aug 27, 2003
Messages
7
Reaction score
0
Hi!

Anyone in for a Byzantine discussion on XML well-formedness?

Here's the situation: test.xml contains

--- test.xml: cut after ---
<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE foobar [
<!ENTITY % decls SYSTEM "test.dtd">
%decls;
]>
<foobar />
--- test.xml: cut before ---

test.dtd initially contains:

--- test.dtd: cut after ---
<?xml version="1.0" encoding="us-ascii"?>
<!ELEMENT foobar EMPTY>
<!ENTITY % addUselessElement SYSTEM "extra.dtd">
<!ENTITY % addUselessElement.it "%addUselessElement;">
<![%addUselessElement.it;[
<!ELEMENT useless EMPTY>
]]>
--- test.dtd: cut before ---

and extra.dtd simply contains

--- extra.dtd: cut after ---
IGNORE
--- extra.dtd: cut before ---

Assertion: text.xml is valid (and, in particular, well-formed). Both OpenSP-1.5 and eXpat (version 1.95.6) agree with me here, so I'll assume I'm right.

Now suppose that in test.dtd the (unique) occurrence of "%addUselessElement.it;" is replaced by "%addUselessElement;". Personally I don't see how this should change anything since one is defined to be equal to the other anyway. And OpenSP still seems happy with the file - but then, OpenSP is an SGML parser, and might not know all the XML well-formedness constraints.

But if I run "xmlwf -p test.xml" (where xmlwf is the program that comes with eXpat) after this change in test.dtd, then I get the following error message

extra.dtd:1:0: syntax error
test.dtd:5:3: error in processing external entity reference test.xml:4:2: error in processing external entity reference

- so eXpat seems to think there is something wrong. I emphasize that this error does not occur with "%addUselessElement.it;" in test.dtd, as written above, only if it is replaced with "%addUselessElement;".
I find this very strange.

Is this a bug in eXpat? I find it hard to believe that, given the number of people who have used and examined this library, I should have found something of the sort. This is why I'd like to have some expert opinion on the question.

Thanks for any thoughts.
 

Richard Tobin

Usenet Archive
Joined
Jan 6, 2000
Messages
4,251
Reaction score
0
David Madore said:
Is this a bug in eXpat?

Hmm, it appears that expat rejects the use of external parameter entities except in literals and when they expand to declarations.

Try

<!ELEMENT foobar %ext;>

where ext is an external parameter entity containing "EMPTY".

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top