473,385 Members | 1,384 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,385 software developers and data experts.

Inheritance in XSD?

I'd like to define a schema that allows, for example, a "table" element that
takes on one of two forms distinguished by what attributes are present. For
instance,

<table foo="3"/>
<table bar="5"/>

Note that I want to exclude <table foo="3" bar = "5"/>; i.e., using *both*
attributes should fail to validate.

A familiar example of this sort of thing is the element named xsd:element in
XML Schema itself. It can have a type attribute or a ref attribute, but not
both. It would appear there are several ways to do this sort of thing. One
approach is to define an abstract tableType, then define derived types
fooTableType and barTableType. We could use extension in which case the
derived types would provide the associated attribute. Alternatively we could
define both attributes in the base type, then derive by restriction, setting
the use of the "excluded" attribute to prohibited. Both approaches seem to
work; i.e., the created XSD seems to past muster in the VS2003 IDE.

The problem is that when I attempt to validate an XML against this XSD I get
an error complaining that the schema is not deterministic due to multiple
elements named "table". Now I've read about the xsi:type attribute and tried
adding that to see if it eliminated the ambiguity, but no joy.

I found the schema for XML Schema at
http://www.w3.org/TR/xmlschema-1/#no...e-schemaSchema and it uses
derivation by restriction to express this sort of thing. Apparently
Microsofts XML implementation however doesn't support this sort of
derivation.

Have I missed something fundamental or is this simply not possible within
the VS2003 IDE and the .Net XML implementation?

Thanks in advance for any suggestions or pointers.

Bill
Nov 12 '05 #1
6 2788
The .NET Framework's XML Schema supports all aspects of XSD including
derivation by restriction. There are probably errors in your schema.

What you want to do is generally not possible with W3C XML Schema. You
cannot create a "choice of attributes". You can define an abstract
tableType, then define derived types fooTableType and barTableType but in
addition should specify that the type of table is tableType in the schema
then each instance declares whether it is a fooTableType or a barTableType
using an xsi:type attribute.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I'd like to define a schema that allows, for example, a "table" element that takes on one of two forms distinguished by what attributes are present. For instance,

<table foo="3"/>
<table bar="5"/>

Note that I want to exclude <table foo="3" bar = "5"/>; i.e., using *both*
attributes should fail to validate.

A familiar example of this sort of thing is the element named xsd:element in XML Schema itself. It can have a type attribute or a ref attribute, but not both. It would appear there are several ways to do this sort of thing. One
approach is to define an abstract tableType, then define derived types
fooTableType and barTableType. We could use extension in which case the
derived types would provide the associated attribute. Alternatively we could define both attributes in the base type, then derive by restriction, setting the use of the "excluded" attribute to prohibited. Both approaches seem to
work; i.e., the created XSD seems to past muster in the VS2003 IDE.

The problem is that when I attempt to validate an XML against this XSD I get an error complaining that the schema is not deterministic due to multiple
elements named "table". Now I've read about the xsi:type attribute and tried adding that to see if it eliminated the ambiguity, but no joy.

I found the schema for XML Schema at
http://www.w3.org/TR/xmlschema-1/#no...e-schemaSchema and it uses
derivation by restriction to express this sort of thing. Apparently
Microsofts XML implementation however doesn't support this sort of
derivation.

Have I missed something fundamental or is this simply not possible within
the VS2003 IDE and the .Net XML implementation?

Thanks in advance for any suggestions or pointers.

Bill

Nov 12 '05 #2
The .NET Framework's XML Schema supports all aspects of XSD including
derivation by restriction. There are probably errors in your schema.

What you want to do is generally not possible with W3C XML Schema. You
cannot create a "choice of attributes". You can define an abstract
tableType, then define derived types fooTableType and barTableType but in
addition should specify that the type of table is tableType in the schema
then each instance declares whether it is a fooTableType or a barTableType
using an xsi:type attribute.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I'd like to define a schema that allows, for example, a "table" element that takes on one of two forms distinguished by what attributes are present. For instance,

<table foo="3"/>
<table bar="5"/>

Note that I want to exclude <table foo="3" bar = "5"/>; i.e., using *both*
attributes should fail to validate.

A familiar example of this sort of thing is the element named xsd:element in XML Schema itself. It can have a type attribute or a ref attribute, but not both. It would appear there are several ways to do this sort of thing. One
approach is to define an abstract tableType, then define derived types
fooTableType and barTableType. We could use extension in which case the
derived types would provide the associated attribute. Alternatively we could define both attributes in the base type, then derive by restriction, setting the use of the "excluded" attribute to prohibited. Both approaches seem to
work; i.e., the created XSD seems to past muster in the VS2003 IDE.

The problem is that when I attempt to validate an XML against this XSD I get an error complaining that the schema is not deterministic due to multiple
elements named "table". Now I've read about the xsi:type attribute and tried adding that to see if it eliminated the ambiguity, but no joy.

I found the schema for XML Schema at
http://www.w3.org/TR/xmlschema-1/#no...e-schemaSchema and it uses
derivation by restriction to express this sort of thing. Apparently
Microsofts XML implementation however doesn't support this sort of
derivation.

Have I missed something fundamental or is this simply not possible within
the VS2003 IDE and the .Net XML implementation?

Thanks in advance for any suggestions or pointers.

Bill

Nov 12 '05 #3
Hi Bill,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #4
Hi Bill,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #5
Dare
Thanks for the response. I will attempt to construct a "simple example"
of this that illustrates the error I'm seeing. Of course in doing so
perhaps I'll find the error if it is indeed mine!

Bill
"Dare Obasanjo [MSFT]" <da***@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
The .NET Framework's XML Schema supports all aspects of XSD including
derivation by restriction. There are probably errors in your schema.

What you want to do is generally not possible with W3C XML Schema. You
cannot create a "choice of attributes". You can define an abstract
tableType, then define derived types fooTableType and barTableType but in
addition should specify that the type of table is tableType in the schema
then each instance declares whether it is a fooTableType or a barTableType
using an xsi:type attribute.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I'd like to define a schema that allows, for example, a "table" element that
takes on one of two forms distinguished by what attributes are present.

For
instance,

<table foo="3"/>
<table bar="5"/>

Note that I want to exclude <table foo="3" bar = "5"/>; i.e., using *both* attributes should fail to validate.

A familiar example of this sort of thing is the element named xsd:element in
XML Schema itself. It can have a type attribute or a ref attribute, but

not
both. It would appear there are several ways to do this sort of thing.

One approach is to define an abstract tableType, then define derived types
fooTableType and barTableType. We could use extension in which case the
derived types would provide the associated attribute. Alternatively we

could
define both attributes in the base type, then derive by restriction,

setting
the use of the "excluded" attribute to prohibited. Both approaches seem to work; i.e., the created XSD seems to past muster in the VS2003 IDE.

The problem is that when I attempt to validate an XML against this XSD I

get
an error complaining that the schema is not deterministic due to multiple elements named "table". Now I've read about the xsi:type attribute and

tried
adding that to see if it eliminated the ambiguity, but no joy.

I found the schema for XML Schema at
http://www.w3.org/TR/xmlschema-1/#no...e-schemaSchema and it uses
derivation by restriction to express this sort of thing. Apparently
Microsofts XML implementation however doesn't support this sort of
derivation.

Have I missed something fundamental or is this simply not possible within the VS2003 IDE and the .Net XML implementation?

Thanks in advance for any suggestions or pointers.

Bill


Nov 12 '05 #6
Dare
Thanks for the response. I will attempt to construct a "simple example"
of this that illustrates the error I'm seeing. Of course in doing so
perhaps I'll find the error if it is indeed mine!

Bill
"Dare Obasanjo [MSFT]" <da***@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
The .NET Framework's XML Schema supports all aspects of XSD including
derivation by restriction. There are probably errors in your schema.

What you want to do is generally not possible with W3C XML Schema. You
cannot create a "choice of attributes". You can define an abstract
tableType, then define derived types fooTableType and barTableType but in
addition should specify that the type of table is tableType in the schema
then each instance declares whether it is a fooTableType or a barTableType
using an xsi:type attribute.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
I'd like to define a schema that allows, for example, a "table" element that
takes on one of two forms distinguished by what attributes are present.

For
instance,

<table foo="3"/>
<table bar="5"/>

Note that I want to exclude <table foo="3" bar = "5"/>; i.e., using *both* attributes should fail to validate.

A familiar example of this sort of thing is the element named xsd:element in
XML Schema itself. It can have a type attribute or a ref attribute, but

not
both. It would appear there are several ways to do this sort of thing.

One approach is to define an abstract tableType, then define derived types
fooTableType and barTableType. We could use extension in which case the
derived types would provide the associated attribute. Alternatively we

could
define both attributes in the base type, then derive by restriction,

setting
the use of the "excluded" attribute to prohibited. Both approaches seem to work; i.e., the created XSD seems to past muster in the VS2003 IDE.

The problem is that when I attempt to validate an XML against this XSD I

get
an error complaining that the schema is not deterministic due to multiple elements named "table". Now I've read about the xsi:type attribute and

tried
adding that to see if it eliminated the ambiguity, but no joy.

I found the schema for XML Schema at
http://www.w3.org/TR/xmlschema-1/#no...e-schemaSchema and it uses
derivation by restriction to express this sort of thing. Apparently
Microsofts XML implementation however doesn't support this sort of
derivation.

Have I missed something fundamental or is this simply not possible within the VS2003 IDE and the .Net XML implementation?

Thanks in advance for any suggestions or pointers.

Bill


Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
10
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.