By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,771 Members | 1,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,771 IT Pros & Developers. It's quick & easy.

external parameter entity references in XML - possible eXpat bug

P: n/a

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">
<foobar />
--- test.xml: cut before ---

test.dtd initially contains:

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

and extra.dtd simply contains

--- extra.dtd: cut after ---
--- 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
";" 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 ";" 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.

David A. Madore
(da**********, )
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
In article <bi***********>,
David Madore <da**********> wrote:
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.


<!ELEMENT foobar %ext;>

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

-- Richard
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.