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

    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?,

    <!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 |

    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

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

    Adrian, Mar 26, 2007
    1. Advertisements

  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 Bina, Mar 27, 2007
    1. Advertisements

  3. Adrian

    Adrian Guest

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

    Peter Flynn Guest

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

    Peter Flynn, Mar 27, 2007
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.