Max and min values in DTD

Discussion in 'XML' started by Mithil, Aug 27, 2007.

  1. Mithil

    Mithil Guest

    HI all,

    Could anyone plz tell me whether max and min values can be specified
    in DTD for an attirbute ? if not is there any way around it ? any help
    and suggestion is greatly appreciated.

    Regards,
    Mithil
     
    Mithil, Aug 27, 2007
    #1
    1. Advertisements

  2. No, it can't be done. DTDs don't provide any way to specify numeric
    ranges. (Unless your range is something small like 1-5, in which case
    you could possibly list all the legal values.)

    The workaround is to use a different schema language, or check the
    value in your application.

    -- Richard
     
    Richard Tobin, Aug 27, 2007
    #2
    1. Advertisements

  3. A DTD does not allow that. The W3C XML schema language however allows it
    using the min/maxInclusive or min/maxExclusive facets:
    http://www.w3.org/TR/xmlschema-2/#rf-facets
     
    Martin Honnen, Aug 27, 2007
    #3
  4. Mithil

    Mithil Guest

    Thanks Martin and Richard
     
    Mithil, Aug 27, 2007
    #4
  5. Mithil

    The Magpie Guest

    Don't think you can do that in a DTD, though you can in a Schema.
     
    The Magpie, Aug 28, 2007
    #5
  6. Which is one of many reasons to consider moving to schemas.

    But remember, DTDs *or* schemas are only an initial sanity-check stage
    -- "higher-order syntax". It's always assumed that the application is
    going to have to enforce semantic constraints.
     
    Joseph Kesselman, Aug 28, 2007
    #6
    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.