By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 922 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

substitutionGroup and extension problem

P: n/a
Hi,

I'm working on an xml schema and I'm running into some problems
relating substitutionGroups and extensions.

This xsd validates fine:
There are three elements and three complex types and every element has
the type of some complexType.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Catalogue">
<xs:complexType>
<xs:sequence>
<xs:element ref="Publication" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publication" type="PublicationType"
abstract="true"/>
<xs:element name="Book" type="BookType"
substitutionGroup="Publication"/>
<xs:element name="Magazine" type="MagazineType"
substitutionGroup="Publication"/>
<xs:complexType name="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:complexContent>
<xs:extension base="PublicationType">
<xs:sequence>
<xs:element name="ISBN" type="xs:string"/>
<xs:element name="Publisher" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MagazineType">
<xs:complexContent>
<xs:restriction base="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="0"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Now, if I change the schema so that the elements extend the complex
type, so instead of <xs:element name="Book" type="BookType"
substitutionGroup="Publication"/>

I say:
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

The schema now looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Catalogue">
<xs:complexType>
<xs:sequence>
<xs:element ref="Publication" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publication" abstract="true">
<xs:complexType>
<xs:complexContent>
<xs:extension base="PublicationType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Magazine" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="MagazineType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:complexContent>
<xs:extension base="PublicationType">
<xs:sequence>
<xs:element name="ISBN" type="xs:string"/>
<xs:element name="Publisher" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MagazineType">
<xs:complexContent>
<xs:restriction base="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="0"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Now, I get an error validating. Xmlspy 2005 says this:
Type Definition "PublicationType" is directly derived from 'anyType'
and, thus, not a valid derivation of 'xs:anyType'.

If I try to validate this schema using .net, I get the following
errors:
Schema parsing error 'Magazine' cannot be a member of substitution
group with head element 'Publication'. An error occurred at , (26, 3).
Schema parsing error 'Book' cannot be a member of substitution group
with head element 'Publication'. An error occurred at , (18, 3).

Anybody know what's wrong with this schema? I thought that <xs:element
name="Book" type="BookType" substitutionGroup="Publication"/>

and:
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

are basically the same, because I'm using an extension, but I'm not
actually 'extending' it by adding any elements or attributes to it.

Thanks in advance,

Jeffry
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Jeffry,

They are not the same thing. Using the second syntax, even though you are
not adding any elements or attributes, you are still creating a new
(anonymous) type that is an extension of BookType. So, when you go to add
Book to the Publication substitutionGroup, the type of Book is not derived
from the type of Publication; their types are "siblings" in the derivation
chain.

Just out of curiosity, is there any reason you don't like the first schema
you showed us? I think that one's a lot more clear and compact, and allows
for further derivation down the line...

Hope that helps,
Priscilla

------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Jeffry van de Vuurst" <go****@vandevuurst.com> wrote in message
news:56**************************@posting.google.c om...
Hi,

I'm working on an xml schema and I'm running into some problems
relating substitutionGroups and extensions.

This xsd validates fine:
There are three elements and three complex types and every element has
the type of some complexType.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Catalogue">
<xs:complexType>
<xs:sequence>
<xs:element ref="Publication" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publication" type="PublicationType"
abstract="true"/>
<xs:element name="Book" type="BookType"
substitutionGroup="Publication"/>
<xs:element name="Magazine" type="MagazineType"
substitutionGroup="Publication"/>
<xs:complexType name="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:complexContent>
<xs:extension base="PublicationType">
<xs:sequence>
<xs:element name="ISBN" type="xs:string"/>
<xs:element name="Publisher" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MagazineType">
<xs:complexContent>
<xs:restriction base="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="0"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Now, if I change the schema so that the elements extend the complex
type, so instead of <xs:element name="Book" type="BookType"
substitutionGroup="Publication"/>

I say:
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

The schema now looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Catalogue">
<xs:complexType>
<xs:sequence>
<xs:element ref="Publication" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publication" abstract="true">
<xs:complexType>
<xs:complexContent>
<xs:extension base="PublicationType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Magazine" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="MagazineType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:complexContent>
<xs:extension base="PublicationType">
<xs:sequence>
<xs:element name="ISBN" type="xs:string"/>
<xs:element name="Publisher" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MagazineType">
<xs:complexContent>
<xs:restriction base="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="0"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Now, I get an error validating. Xmlspy 2005 says this:
Type Definition "PublicationType" is directly derived from 'anyType'
and, thus, not a valid derivation of 'xs:anyType'.

If I try to validate this schema using .net, I get the following
errors:
Schema parsing error 'Magazine' cannot be a member of substitution
group with head element 'Publication'. An error occurred at , (26, 3).
Schema parsing error 'Book' cannot be a member of substitution group
with head element 'Publication'. An error occurred at , (18, 3).

Anybody know what's wrong with this schema? I thought that <xs:element
name="Book" type="BookType" substitutionGroup="Publication"/>

and:
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

are basically the same, because I'm using an extension, but I'm not
actually 'extending' it by adding any elements or attributes to it.

Thanks in advance,

Jeffry

Nov 12 '05 #2

P: n/a
Hi Priscilla,

So if I understand correctly.

What you're saying is that if I extend BookType in my Book element I create
an anonymous type. So would this be basically the same as doing this?:

<xs:complexType name="ExtendedBookType">
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ExtendedBookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

And, the type of Book should derive DIRECTLY from the type of Publication?
It is not that if Book derives from ExtendedBookType, ExtendedBookType
derives from BookType and BookType derives from PublicationType, that I can
substitute the Book element for the Publication element?

Anyway, I too like the first schema best. That was what I came up with as a
response to the second schema that I received from my customer. We are now
discussing the schema's and with your explanation I can argue that the
second schema is not correct. Well, I knew it was not correct, because it
didn't validate, but now I know why (at least, if my abovementioned
understanding of your explanation is correct) :)

Thanks a lot,
Jeffry

"Priscilla Walmsley" <no****@datypic.com> wrote in message
news:eC**************@tk2msftngp13.phx.gbl...
Hi Jeffry,

They are not the same thing. Using the second syntax, even though you are
not adding any elements or attributes, you are still creating a new
(anonymous) type that is an extension of BookType. So, when you go to add
Book to the Publication substitutionGroup, the type of Book is not derived
from the type of Publication; their types are "siblings" in the derivation
chain.

Just out of curiosity, is there any reason you don't like the first schema
you showed us? I think that one's a lot more clear and compact, and
allows for further derivation down the line...

Hope that helps,
Priscilla

------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Jeffry van de Vuurst" <go****@vandevuurst.com> wrote in message
news:56**************************@posting.google.c om...
Hi,

I'm working on an xml schema and I'm running into some problems
relating substitutionGroups and extensions.

This xsd validates fine:
There are three elements and three complex types and every element has
the type of some complexType.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Catalogue">
<xs:complexType>
<xs:sequence>
<xs:element ref="Publication" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publication" type="PublicationType"
abstract="true"/>
<xs:element name="Book" type="BookType"
substitutionGroup="Publication"/>
<xs:element name="Magazine" type="MagazineType"
substitutionGroup="Publication"/>
<xs:complexType name="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:complexContent>
<xs:extension base="PublicationType">
<xs:sequence>
<xs:element name="ISBN" type="xs:string"/>
<xs:element name="Publisher" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MagazineType">
<xs:complexContent>
<xs:restriction base="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="0"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Now, if I change the schema so that the elements extend the complex
type, so instead of <xs:element name="Book" type="BookType"
substitutionGroup="Publication"/>

I say:
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

The schema now looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Catalogue">
<xs:complexType>
<xs:sequence>
<xs:element ref="Publication" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Publication" abstract="true">
<xs:complexType>
<xs:complexContent>
<xs:extension base="PublicationType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="Magazine" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="MagazineType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="BookType">
<xs:complexContent>
<xs:extension base="PublicationType">
<xs:sequence>
<xs:element name="ISBN" type="xs:string"/>
<xs:element name="Publisher" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="MagazineType">
<xs:complexContent>
<xs:restriction base="PublicationType">
<xs:sequence>
<xs:element name="Title" type="xs:string"/>
<xs:element name="Author" type="xs:string" minOccurs="0"
maxOccurs="0"/>
<xs:element name="Date" type="xs:gYear"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Now, I get an error validating. Xmlspy 2005 says this:
Type Definition "PublicationType" is directly derived from 'anyType'
and, thus, not a valid derivation of 'xs:anyType'.

If I try to validate this schema using .net, I get the following
errors:
Schema parsing error 'Magazine' cannot be a member of substitution
group with head element 'Publication'. An error occurred at , (26, 3).
Schema parsing error 'Book' cannot be a member of substitution group
with head element 'Publication'. An error occurred at , (18, 3).

Anybody know what's wrong with this schema? I thought that <xs:element
name="Book" type="BookType" substitutionGroup="Publication"/>

and:
<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

are basically the same, because I'm using an extension, but I'm not
actually 'extending' it by adding any elements or attributes to it.

Thanks in advance,

Jeffry


Nov 12 '05 #3

P: n/a
Hi Jeffry,
What you're saying is that if I extend BookType in my Book element I
create an anonymous type. So would this be basically the same as doing
this?: <xs:complexType name="ExtendedBookType">
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ExtendedBookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
No, now the type of Book is an anonymous type that is an extension of
ExtendedBookType, which itself is an extension of BookType. That's not the
same thing as:

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

where the type of Book is an anonymous type that is an extension of BookType
(2 types instead of 3).
And, the type of Book should derive DIRECTLY from the type of Publication?
It is not that if Book derives from ExtendedBookType, ExtendedBookType
derives from BookType and BookType derives from PublicationType, that I
can substitute the Book element for the Publication element?
It doesn't have to be directly derived from it. But in your 2nd schema the
Publication element doesn't have the type PublicationType, it has an
anonymous type that is an extension of PublicationType. So what you have
is:

PublicationType
| |
anon1 BookType
|
anon2

where anon1 is the type of Publication and anon2 is the type of Book. anon2
is not considered to be derived from anon1 because it is not a descendent of
anon1.

Does that make sense?

Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Jeffry van de Vuurst" <re***@to.newsgroup> wrote in message
news:Oy**************@TK2MSFTNGP14.phx.gbl... Hi Priscilla,

So if I understand correctly.

What you're saying is that if I extend BookType in my Book element I
create an anonymous type. So would this be basically the same as doing
this?:

<xs:complexType name="ExtendedBookType">
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ExtendedBookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

And, the type of Book should derive DIRECTLY from the type of Publication?
It is not that if Book derives from ExtendedBookType, ExtendedBookType
derives from BookType and BookType derives from PublicationType, that I
can substitute the Book element for the Publication element?

Anyway, I too like the first schema best. That was what I came up with as
a response to the second schema that I received from my customer. We are
now discussing the schema's and with your explanation I can argue that the
second schema is not correct. Well, I knew it was not correct, because it
didn't validate, but now I know why (at least, if my abovementioned
understanding of your explanation is correct) :)

Thanks a lot,
Jeffry

Nov 12 '05 #4

P: n/a
Oh stupid me, I meant to say this:

<xs:complexType name="ExtendedBookType">
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Book" type="ExtendedBookType"
substitutionGroup="Publication">
</xs:element>

But that doesn't make a difference, because of your explanation:
PublicationType
| |
anon1 BookType
|
anon2

So in the case of what I meant to say, this diagram would look like
PublicationType
| |
anon1 BookType
|
ExtendedBookType

Also in this case the type of Book (ExtendedBookType) doesn't derive from
the type of Publication (anon1).

I think to point is, which I didn't know and you made perfectly clear, that
if an element extends a type, it now has an anonymous type that extends from
that type. And that's what causes all the confusion. Right? I hope so :)

Thanks you very much for your explanation.

Jeffry


"Priscilla Walmsley" <no****@datypic.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi Jeffry,
What you're saying is that if I extend BookType in my Book element I
create an anonymous type. So would this be basically the same as doing
this?:

<xs:complexType name="ExtendedBookType">
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ExtendedBookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>


No, now the type of Book is an anonymous type that is an extension of
ExtendedBookType, which itself is an extension of BookType. That's not
the same thing as:

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

where the type of Book is an anonymous type that is an extension of
BookType (2 types instead of 3).
And, the type of Book should derive DIRECTLY from the type of
Publication? It is not that if Book derives from ExtendedBookType,
ExtendedBookType derives from BookType and BookType derives from
PublicationType, that I can substitute the Book element for the
Publication element?


It doesn't have to be directly derived from it. But in your 2nd schema
the Publication element doesn't have the type PublicationType, it has an
anonymous type that is an extension of PublicationType. So what you have
is:

PublicationType
| |
anon1 BookType
|
anon2

where anon1 is the type of Publication and anon2 is the type of Book.
anon2 is not considered to be derived from anon1 because it is not a
descendent of anon1.

Does that make sense?

Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Jeffry van de Vuurst" <re***@to.newsgroup> wrote in message
news:Oy**************@TK2MSFTNGP14.phx.gbl...
Hi Priscilla,

So if I understand correctly.

What you're saying is that if I extend BookType in my Book element I
create an anonymous type. So would this be basically the same as doing
this?:

<xs:complexType name="ExtendedBookType">
<xs:complexContent>
<xs:extension base="BookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="Book" substitutionGroup="Publication">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ExtendedBookType">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>

And, the type of Book should derive DIRECTLY from the type of
Publication? It is not that if Book derives from ExtendedBookType,
ExtendedBookType derives from BookType and BookType derives from
PublicationType, that I can substitute the Book element for the
Publication element?

Anyway, I too like the first schema best. That was what I came up with as
a response to the second schema that I received from my customer. We are
now discussing the schema's and with your explanation I can argue that
the second schema is not correct. Well, I knew it was not correct,
because it didn't validate, but now I know why (at least, if my
abovementioned understanding of your explanation is correct) :)

Thanks a lot,
Jeffry


Nov 12 '05 #5

P: n/a
Hi Jeffry,
I think to point is, which I didn't know and you made perfectly clear,
that if an element extends a type, it now has an anonymous type that
extends from that type. And that's what causes all the confusion. Right? I
hope so :)


Exactly!

Priscilla

------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.