Text OR Fixed structure in an ELEMENT

Discussion in 'XML' started by luckyroom505@yahoo.com, Nov 22, 2005.

  1. Guest

    Hello,

    I try to make a DTD for a structure like this:

    <notelist>
    <note><to>john</to><subj>i have a question</subj></note>
    <note>my pin code is 1111</note>
    </notelist>

    I tried:

    <!DOCTYPE notelist[
    <!ELEMENT notelist (note*)>
    <!ELEMENT note (#PCDATA|(to, subj)) >
    <!ELEMENT to (#PCDATA)>
    <!ELEMENT subj (#PCDATA)>
    ]>

    but it does not validate (iE6.0)

    Any ideas?
    LR
    , Nov 22, 2005
    #1
    1. Advertising

  2. In article <>,
    <> wrote:

    >I try to make a DTD for a structure like this:
    >
    ><notelist>
    ><note><to>john</to><subj>i have a question</subj></note>
    ><note>my pin code is 1111</note>
    ></notelist>


    You can't do that in a DTD. The best you can do is allow any mixture
    of <to>, <subj>, and text.

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

    -- Richard
    Richard Tobin, Nov 22, 2005
    #2
    1. Advertising

  3. > In article <>,
    > <> wrote:
    >>I try to make a DTD for a structure like this:
    >>
    >><notelist>
    >><note><to>john</to><subj>i have a question</subj></note>
    >><note>my pin code is 1111</note>
    >></notelist>


    Richard Tobin wrote:
    > You can't do that in a DTD. The best you can do is allow any mixture
    > of <to>, <subj>, and text.


    Or use two different elements:
    <structuredNote><to>john</to><subj>i have a question</subj></structuredNote>
    <note>my pin code is 1111</note>
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
    Johannes Koch, Nov 22, 2005
    #3
  4. Harrie Guest

    Johannes Koch said the following on 11/22/2005 14:08 +0200:
    >> In article <>,
    >> <> wrote:
    >>
    >>> I try to make a DTD for a structure like this:
    >>>
    >>> <notelist>
    >>> <note><to>john</to><subj>i have a question</subj></note>
    >>> <note>my pin code is 1111</note>
    >>> </notelist>

    >
    > Richard Tobin wrote:
    >
    >> You can't do that in a DTD. The best you can do is allow any mixture
    >> of <to>, <subj>, and text.

    >
    > Or use two different elements:
    > <structuredNote><to>john</to><subj>i have a
    > question</subj></structuredNote>
    > <note>my pin code is 1111</note>


    Or eliminate one "note" element (I renamed some elements, it made more
    sence to me that way, YMMV).

    <note>
    <to>john</to>
    <subj>i have a question</subj>
    <text>my pin code is 1111</text>
    </note>

    --
    Regards
    Harrie
    Harrie, Nov 23, 2005
    #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. Andreas Pardeike
    Replies:
    7
    Views:
    965
  2. johnp
    Replies:
    4
    Views:
    3,655
    Toby Inkster
    May 23, 2005
  3. monique
    Replies:
    3
    Views:
    482
    monique
    Jan 27, 2006
  4. Rob Stampfli
    Replies:
    1
    Views:
    430
    Spartanicus
    May 17, 2006
  5. HANM
    Replies:
    2
    Views:
    698
    Joseph Kesselman
    Jan 29, 2008
Loading...

Share This Page