Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 27th, 2006, 02:06 PM
Steve
Guest
 
Posts: n/a
Default A beginners question about substitution groups

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.

  #2  
Old February 27th, 2006, 05:05 PM
Priscilla Walmsley
Guest
 
Posts: n/a
Default Re: A beginners question about substitution groups

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/defxmls...r11.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 ***
  #3  
Old February 28th, 2006, 10:25 AM
Steve
Guest
 
Posts: n/a
Default Re: A beginners question about substitution groups

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.

 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles