DTD element type declaration

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

    #1

    DTD element type declaration

    Hi,

    Trying to validate this dtd example with xml-spy 5 pro:

    This works:
    <!ELEMENT note (#PCDATA|body)* >
    <!ELEMENT body (#PCDATA)>

    This doesnt:
    <!ELEMENT note (#PCDATA|body)>
    <!ELEMENT body (#PCDATA)>

    Is this a bug when 'char or char' is allowed when repeating zero or more times?

    Thanks,

    Imiro
  • Keith M. Corbett

    #2
    Re: DTD element type declaration

    "Imiro" <dar_imiro@hotm ail.com> wrote in message
    news:b6ec536f.0 408241217.15bc2 425@posting.goo gle.com...[color=blue]
    > Trying to validate this dtd example with xml-spy 5 pro:
    >
    > This works:
    > <!ELEMENT note (#PCDATA|body)* >
    > <!ELEMENT body (#PCDATA)>
    >
    > This doesnt:
    > <!ELEMENT note (#PCDATA|body)>
    > <!ELEMENT body (#PCDATA)>[/color]


    The SP parser (nsgmls program) reports the error "#PCDATA in model group
    that does not have REP occurrence indicator".

    The "SGML Handbook" offers this explanation: "#PCDATA should be used in a
    content model only when the intention of the content model is to allow
    inter-mixed data with whatever elements are permitted - in other words,
    where the content model is a repeatable OR group."

    If you really need to restrict the note element to contain one body, you
    might want to avoid the mixed content model altogether. (Mixed content means
    parsed character data may be mixed with element content.) Something like
    this:

    <!ELEMENT note (comment?, body, comment?)>
    <!ELEMENT comment (#PCDATA)>
    <!ELEMENT body (#PCDATA)>

    /kmc


    Comment

    • Richard Tobin

      #3
      Re: DTD element type declaration

      In article <b6ec536f.04082 41217.15bc2425@ posting.google. com>,
      Imiro <dar_imiro@hotm ail.com> wrote:
      [color=blue]
      >This doesnt:
      ><!ELEMENT note (#PCDATA|body)>[/color]

      That's not allowed. The only legal mixed content declarations are
      ones of the form

      (#PCDATA)
      (#PCDATA)*
      (#PCDATA | name | name ...)*

      See http://www.w3.org/TR/REC-xml/#sec-mixed-content

      -- Richard

      Comment

      • Imiro

        #4
        Re: DTD element type declaration

        Thanks, this was what i needed to know. I'm Converting old sgml DTD
        thats loaded with mixed content, that won't validate :P

        --Imiro

        Comment

        Working...