D
David Madore
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.
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.