external parameter entity references in XML - possible eXpat bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Madore

    #1

    external parameter entity references in XML - possible eXpat bug

    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 % addUselessEleme nt SYSTEM "extra.dtd" >
    <!ENTITY % addUselessEleme nt.it "%addUselessEle ment;">
    <![%addUselessElem ent.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
    "%addUselessEle ment.it;" is replaced by "%addUselessEle ment;".
    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 "%addUselessEle ment.it;" in test.dtd,
    as written above, only if it is replaced with "%addUselessEle ment;".
    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
    (david.madore@e ns.fr,
    http://www.eleves.ens.fr:8080/home/madore/ )
  • Richard Tobin

    #2
    Re: external parameter entity references in XML - possible eXpat bug

    In article <bii6hj$2osn$1@ nef.ens.fr>,
    David Madore <david.madore@e ns.fr> wrote:
    [color=blue]
    >Is this a bug in eXpat?[/color]

    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


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

    FreeBSD rules!

    Comment

    Working...