RE: Substitution groups and xsi:type

Hi Jeff. Thanks for the explanation. I have also
re-read Mr Costello's variable content container
best practice which gave me another perspective.

If I understand correctly,


There is some commonality between element and
type substitution

1. Both make writing schemas simpler in that you
don't have to explictly spell out all the possible
combinations - you simply reference the base
element/type.

2. Both rely on a type hierachy - the substituted
element type or type indicated by the xsi:type attribute
must be part of the type hierachy of the element/type
used in the schema.

3. Substitution is one way. If type B is derived from
type A and I use type A in my schema, I can substitute
type B in my instance but not vica-versa.

Similarly, substitution element B and its head A may
share the same type, but is not legal to substitute
A for B in an instance document, were B to be used
in the corresponding schema. It would however be
legal to substitute B in an instance wherever A was
used in the corresponding schema.


In terms of instance document processing,

1. In the case of element substitution, the schema validator
can determine the type the instance author is using via the
name of the substituted element.

2. In the case of xsi:type, the element name is the common so
the author tells the schema validator what type to expect
via the xsi:type attribute.

3. The validator is not implying anything - it looks at what the
instance author explicitly provides via the element name/xsi:type
and performs its' checks accordingly.


Am I back on the road?

Regards
Michael






                                                                                                                                             
                    Jeff Lowery                                                                                                              
                    <jlowery@scenicsof        To:     "'Mike_Leditschke@nemmco.com.au'" <Mike_Leditschke@nemmco.com.au>,                     
                    t.com>                    xmlschema-dev@w3.org                                                                           
                    Sent by:                  cc:                                                                                            
                    xmlschema-dev-requ        Subject:     RE: Substitution groups and xsi:type                                              
                    est@w3.org                                                                                                               
                                                                                                                                             
                                                                                                                                             
                    19/05/2001 03:01                                                                                                         
                    AM                                                                                                                       
                                                                                                                                             
                                                                                                                                             



Don't confuse element substitution with type substitution. The reason to
use
xsi:type in a document is indicate that the default element type (the one
defined for the element in the schema) has be 'substituted' with a derived
type.

A substitution group allows one element to be substituted for another, so
long at the types are the same or the substituted element's is a derived
type. The xsi:type isn't necessary, becuase the defualt type for the
substituted element is in use.

It is possible to combine element substitution with type substitution:
substitute an element, then substitute its type with a derived type.

I hope that's not too confusing of an explanation (and it may even be
substantially correct).

Jeff

> -----Original Message-----
> From: Mike_Leditschke@nemmco.com.au
> [mailto:Mike_Leditschke@nemmco.com.au]
> Sent: Friday, May 18, 2001 9:36 AM
> To: xmlschema-dev@w3.org
> Subject: Substitution groups and xsi:type
>
>
> In section 4.6 of the primer, two statements are made...
>
> 1. "Elements in a substitution group must have the same
> type as the head element, or they can have a type that has been
> derived from the head element's type"
>
> then later
>
> 2. "..when an instance document contains element substitutions
> whose types are derived from those of their head elements, it is
> not necessary to identify the derived types using the xsi:type
> construction..."
>
>
> I think the wording of the second is tripping me up a bit given
> that, assuming the first statement, I can't see how you'd
> ever get a case where the second didn't apply, that is,
>
> an instance document containing element substitutions, whose
> types WEREN'T derived from those of the head etc and hence
> who WOULD have to use the xsi:type attribute.
>
> Is the intent to say, if you use an element substitution, the
> rules about
> providing xsi:type attributes in instance documents don't apply?
>
>
>
> On a similar vein, it appears that for substitution groups to work,
> validators are capable of working
> out "for themselves" which particular substitution group element has
> been provided in an instance document without the instance author
> explicitly telling the validator.
>
> It seems a small step to ask why then, I need to provide xsi:type
> attributes at all, given that the validator knows the set of
> types that
> could possbily be used i.e. those derived from the base type used
> in the schema defining the instance document.
>
> What additional "magic" is enabled by explictly tying a series of
> related elements (and by implication types) together via
> substitutionGroup attribute
>
>
>
> I've probably gone off the road completely somewhere. A pointer to
> the skid marks would be appreciated.
>
> Regards
> Michael
>

Received on Saturday, 19 May 2001 08:29:22 UTC