W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2011

Re: What is lost if xsd:choice is jettisoned?

From: George Cristian Bina <george@oxygenxml.com>
Date: Wed, 09 Mar 2011 13:24:40 +0200
Message-ID: <4D776378.50009@oxygenxml.com>
To: "Costello, Roger L." <costello@mitre.org>
CC: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Roger,

Just a couple of additional notes on this.

A reference to and element that is a substitution group head expands 
itself as a choice particle. As you already noted in the replies you got 
so far that cannot replace the choice particle from XML Schema. Where 
substitution groups are particularly interesting in my opinion is that 
they allow to overcome some of the limitations of the type extension in 
XML Schema. For example, imagine you have a paragraph and you want to 
define that its content is text plus some inline elements like bold and 
italic. If you put that in a complex type then you will have a content 
type like below


plus marking the type as mixed to allow text content.

Now, imagine that you need to extend this to add underline as a possible 
inline element. If you make an extension to the type you defined you 
will end up with a content model like

(bold|italic)*, underline*

so, you will be able to use underline only at the end.

On the other hand, if you define an element, let's say inline and make 
the content model


and then define bold and italic with inline as substitution head then 
when you want to have also underline as a possible element inside that 
content model then you just mark underline with inline as substitution 
head and the reference to inline will be automatically expanded to a 
choice of bold, italic and underline. So basically you can see the 
substitution support as providing a dynamic type of choice, that is 
obtain depending on whatever elements substitute that referred element 
and that can change depending on what schema components are defined to 
substitute it.

Best Regards,
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

On 3/8/11 4:45 PM, George Cristian Bina wrote:
> Hi Roger,
> When you use substitution groups there are additional constraints on the
> type of the elements that can substitute an element while when using
> plain choice there are no such constraints.
> Actually the content model when you have substitution groups like in
> your example is a choice between all the elements that can substitute
> that element. This will not work very well I think if you need to
> specify something like
> (a, b) | (b, c)
> for example, or something more complex along these lines.
> Best Regards,
> George
Received on Wednesday, 9 March 2011 11:25:15 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:18 UTC