DTD and parameter entity replacement

Discussion in 'XML' started by Tuomas Rannikko, Jun 9, 2006.

  1. Hello!

    I have a simple question about DTDs: Should this be possible?

    <!DOCTYPE root [

    <!ELEMENT root (#PCDATA)>

    <!ELEMENT this EMPTY>
    <!ELEMENT that EMPTY>
    <!ENTITY % param "that">

    <!ELEMENT test (this, %param;)>
    ]
    >


    In the XML specification I can't find the spot where it says this would
    be disallowed; however Xerces complains about the parameter entity being
    in markup.

    - Tuomas
     
    Tuomas Rannikko, Jun 9, 2006
    #1
    1. Advertising

  2. >In the XML specification I can't find the spot where it says this
    would >be disallowed

    In section 2.8, down a little ways:

    "Well-Formedness Constraint: PEs in Internal Subset
    In the internal DTD subset, parameter-entity references can occur only
    where markup declarations can occur, not within markup declarations.
    (This does not apply to references that occur in external parameter
    entities or to the external subset.)"

    Tim Bray's _Annotated_XML_Specification_
    (http://www.xml.com/axml/testaxml.htm) has a comment on why this rule
    was put in place. (That site is an excellent resource for understanding
    why XML 1.0 is as it is. Unfortunately, Tim has said he probably won't
    have time to bring it up to date for XML 1.1, never mind namespaces and
    so on. There's an opportunity here for someone to contribute to the
    community.)

    For what it's worth, Appendix D shows a hideous workaround, which
    involves constructing the whole entity definition in a single parameter
    entity and using that. To find it, search for "error-prone" -- which it
    is, and I strongly recommend that you find another solution.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Jun 9, 2006
    #2
    1. Advertising

  3. Tuomas Rannikko

    Peter Flynn Guest

    Tuomas Rannikko wrote:
    > Hello!
    >
    > I have a simple question about DTDs: Should this be possible?


    Yes, but not in an Internal Subset.

    > <!DOCTYPE root [
    >
    > <!ELEMENT root (#PCDATA)>


    This should probably be "test", not "#PCDATA".

    > <!ELEMENT this EMPTY>
    > <!ELEMENT that EMPTY>
    > <!ENTITY % param "that">
    >
    > <!ELEMENT test (this, %param;)>
    > ]
    > >

    >
    > In the XML specification I can't find the spot where it says this would
    > be disallowed; however Xerces complains about the parameter entity being
    > in markup.


    Joe has pointed out where. Just snip out the declarations and put them
    in test.dtd (with the content model for "root" being "test"), then

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE root SYSTEM "test.dtd">
    <root>
    <test>
    <this/>
    <that/>
    </test>
    </root>

    is a valid instance.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Jun 10, 2006
    #3
  4. Joe Kesselman wrote:
    > >In the XML specification I can't find the spot where it says this

    > would >be disallowed
    >
    > In section 2.8, down a little ways:
    >
    > "Well-Formedness Constraint: PEs in Internal Subset
    > In the internal DTD subset, parameter-entity references can occur only
    > where markup declarations can occur, not within markup declarations.
    > (This does not apply to references that occur in external parameter
    > entities or to the external subset.)"
    >
    > Tim Bray's _Annotated_XML_Specification_
    > (http://www.xml.com/axml/testaxml.htm) has a comment on why this rule
    > was put in place. (That site is an excellent resource for understanding
    > why XML 1.0 is as it is. Unfortunately, Tim has said he probably won't
    > have time to bring it up to date for XML 1.1, never mind namespaces and
    > so on. There's an opportunity here for someone to contribute to the
    > community.)
    >


    Ah, yes. I seem to have mixed up my concepts. I had trouble seeing as to
    why that would not be allowed, but the annotated specification helps to
    clarify that it's allowed ONLY in external subsets (and why).

    I guess I'll have to keep track whether I'm parsing an external or
    internal subset. (I'm writing a parser just for the fun of it ;) )

    Thanks,
    - Tuomas
     
    Tuomas Rannikko, Jun 20, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,740
    Jukka K. Korpela
    Feb 24, 2007
  2. tastyrerun
    Replies:
    1
    Views:
    425
    Bjoern Hoehrmann
    Jun 14, 2007
  3. markla
    Replies:
    1
    Views:
    580
    Steven Cheng
    Oct 6, 2008
  4. Norm
    Replies:
    3
    Views:
    2,876
  5. ThatsIT.net.au

    Entity, problem with entity key

    ThatsIT.net.au, Sep 6, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    1,244
    ThatsIT.net.au
    Sep 7, 2009
Loading...

Share This Page