473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

substitutionGroup and extension problem

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
5 3366
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Gyger | last post by:
Hello, Three weeks ago, I have started to develop a binding extension for Qt and PHP 5. Now, I can display a dialog box containing some widgets like label, buttons and edit line. I have just...
3
by: Peter Sparago | last post by:
(Sorry in advance for the long post.) Hi, I'm having a great deal of difficulty buiding a Python COM extension. I am using the MSHTML ActiveX control in my application but I need to interact...
1
by: Val Melamed | last post by:
Hi all, These days I'm playing with schemas and SOM from MSXML. To learn it I used the excellent tutorial from Mr.Costello: http://www.xfront.com/xml-schema.html. while working through the...
3
by: man-in-nature | last post by:
Hello, I have already read several existing posts about xsd:extension, but do not find something useful to my test case. I have one xml file and one xsd file. I can use a simple command line...
0
by: XSD-optimist | last post by:
I am trying to generate the classes for an XSD schema using the Microsoft XSD Object Code Generator (XSDObjGen). I am having a schema that contains the definition of the following: 1. a complex...
3
by: Michael Skulsky | last post by:
Hi all, I've got the following validation problem. There are 2 schemas and a document: ----------------------------------------------------------------- bar.xsd ====== <?xml version="1.0"...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
4
by: pepcag | last post by:
I used http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp as a template to create a very simple web method with soap...
6
by: tommybiegs | last post by:
I'm having a weird problem. I can't seem to force php to load an extension using php.ini, but it loads perfectly if I use dl() at the beginning of a test script. In php.ini I've got: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.