How to define elements in a dtd

Discussion in 'XML' started by Adrian, Mar 26, 2007.

  1. Adrian

    Adrian Guest

    I cannot find a way to define an element so that it contains sub
    elements in any order but only 1 of each.

    I have tried a sequence of but then the order matters
    I have tried a choice of 0 or more but then I can add an element in
    twice.

    Here is what I have tried so far
    <!ELEMENT fields (type?, expiry_date?, ccmy?, commodity_name?,
    exchange_symbol?, notice_date?, related_option?, action_ptr?,
    double_quote_to?, double_quote_from?, retransmission?, active_index?,
    title?)>


    <!ELEMENT fields (type | expiry_date | ccmy | commodity_name |
    exchange_symbol | notice_date | related_option | action_ptr |
    double_quote_to | double_quote_from | retransmission | active_index |
    title)*>


    So in <fields> I want 0 or 1 of each field but I dont want to specifiy
    an order for the elements in <fields>. Is this possible in a dtd
    definition.

    This has to be a dtd too, our xml library doesnt support schemas and
    cannot be changed.


    Adrian
    Adrian, Mar 26, 2007
    #1
    1. Advertising

  2. Adrian

    George Bina Guest

    Hi Adrian,

    No, that is not possible in a DTD. You need to either constrain the
    model to a specific order as in your sequence case or define a more
    relaxed model and enforce the constraints at application level.

    Best Regards,
    George
    ---------------------------------------------------------------------
    George Cristian Bina
    <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
    http://www.oxygenxml.com


    On Mar 26, 6:40 pm, "Adrian" <> wrote:
    > I cannot find a way to define an element so that it contains sub
    > elements in any order but only 1 of each.
    >
    > I have tried a sequence of but then the order matters
    > I have tried a choice of 0 or more but then I can add an element in
    > twice.
    >
    > Here is what I have tried so far
    > <!ELEMENT fields (type?, expiry_date?, ccmy?, commodity_name?,
    > exchange_symbol?, notice_date?, related_option?, action_ptr?,
    > double_quote_to?, double_quote_from?, retransmission?, active_index?,
    > title?)>
    >
    > <!ELEMENT fields (type | expiry_date | ccmy | commodity_name |
    > exchange_symbol | notice_date | related_option | action_ptr |
    > double_quote_to | double_quote_from | retransmission | active_index |
    > title)*>
    >
    > So in <fields> I want 0 or 1 of each field but I dont want to specifiy
    > an order for the elements in <fields>. Is this possible in a dtd
    > definition.
    >
    > This has to be a dtd too, our xml library doesnt support schemas and
    > cannot be changed.
    >
    > Adrian
    George Bina, Mar 27, 2007
    #2
    1. Advertising

  3. Adrian

    Adrian Guest

    On Mar 27, 1:24 am, "George Bina" <> wrote:
    > Hi Adrian,
    >
    > No, that is not possible in a DTD. You need to either constrain the
    > model to a specific order as in your sequence case or define a more
    > relaxed model and enforce the constraints at application level.
    > - Show quoted text -


    Thanks George. I just assumed it was possible in the DTD.
    Adrian, Mar 27, 2007
    #3
  4. Adrian

    Peter Flynn Guest

    Adrian wrote:
    > On Mar 27, 1:24 am, "George Bina" <> wrote:
    >> Hi Adrian,
    >>
    >> No, that is not possible in a DTD. You need to either constrain the
    >> model to a specific order as in your sequence case or define a more
    >> relaxed model and enforce the constraints at application level.
    >> - Show quoted text -

    >
    > Thanks George. I just assumed it was possible in the DTD.


    It *is* possible in a DTD, but only when using SGML, not XML.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
    Peter Flynn, Mar 27, 2007
    #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. Joseph Tilian
    Replies:
    0
    Views:
    339
    Joseph Tilian
    Dec 21, 2004
  2. Ronald Fischer
    Replies:
    4
    Views:
    1,743
    Ronald Fischer
    Mar 17, 2005
  3. Ha
    Replies:
    1
    Views:
    851
    arnold m. slotnik
    Jan 28, 2004
  4. Doug Estep
    Replies:
    4
    Views:
    723
    Oliver Bonten
    Feb 2, 2004
  5. test
    Replies:
    2
    Views:
    1,995
    Oliver Wong
    Jul 28, 2006
Loading...

Share This Page