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