A beginners question about substitution groups

Discussion in 'XML' started by Steve, Feb 27, 2006.

  1. Steve

    Steve Guest

    Hi,

    I'm currently teaching myself about XML schems at the same time as
    specifying the XML document for a project I've been given to write.
    (I'm new to the XML world, so progress is a little slow at the moment!)

    I find myself needing to restrict an element to contain either an
    integer in the range of 01 - 99 OR the value "*9". Because of the
    asterisk an simple integer field is not sufficient so I suspect I need
    to use a substitution group to specify that this element can either be
    an integer, or a string with only one permissable value.

    I'm following the XML Schema Part 0 - 3 from the w3c.org website to
    indicate what is permissible in the language.

    I'm a little confused about how to code up a substitution group so that
    the value is either a ranged integer, or a specific string. Could
    someone point me in the direction of some other documentation which is
    a little more readable than the official primer, or describe to me how
    it's done - I don't want some canned XML with "This will do what you
    require", as I'd like to work this simple problem through myself.

    Cheers.
    Steve, Feb 27, 2006
    #1
    1. Advertising

  2. Hi,

    You actually need a union type rather than a substitution group. The
    Primer has some coverage on that:

    http://www.w3.org/TR/xmlschema-0/#UnionDt

    There is an example of a union type from my book (and many more schema
    examples) at:

    http://www.datypic.com/books/defxmlschema/chapter11.html#EX116

    Hope that helps,
    Priscilla

    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    Definitive XQuery
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Priscilla Walmsley, Feb 27, 2006
    #2
    1. Advertising

  3. Steve

    Steve Guest

    Aha! A union (which I'd not actually read about yet) is definitely the
    way to go. I think that I may do well with a comfortable book, rather
    than the precise, but slightly terse, standards docs!

    Seeing as you've written both, it I feel I should look no further! :)

    Many thanks Priscilla - my schema is rolling again...

    Steve.
    Steve, Feb 28, 2006
    #3
    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. Petra Hübner
    Replies:
    0
    Views:
    426
    Petra Hübner
    Feb 16, 2004
  2. John Carron
    Replies:
    2
    Views:
    841
    John Carron
    Sep 2, 2005
  3. John Carron
    Replies:
    0
    Views:
    462
    John Carron
    Sep 1, 2005
  4. Soren Kuula
    Replies:
    2
    Views:
    560
    Soren Kuula
    Feb 3, 2006
  5. sisyphus
    Replies:
    16
    Views:
    186
    Nathan Keel
    Apr 30, 2009
Loading...

Share This Page