You can do what you want by adding the following uniquness constraint to the
<characteristicelement (before </xs:element>):
<xs:unique name="value_or_values">
<xs:selector xpath="."/>
<xs:field xpath="@values|mytns:value"/>
</xs:unique>
Note, this assumes that you have defined a target namespace for your schema
and its prefix is mytns. If you don't have the target namespace defined,
you will need to define it (and assign a prefix to it).
--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Eric" <emleml@hotmail.comwrote in message
news:1173293194.874932.29310@h3g2000cwc.googlegrou ps.com...
Quote:
Attached is an example of my question. Note the "values" attribute is
optional. Also the <valuesub-element is optional. Here, the XML
can contain, 1 or both or neither. I would like to allow EITHER the
"values" attribute or <valuesub-elements - but not both.
>
I tried using a <choicewith two element definitions for
"characteristic" with different content, but this is clearly not
allowed in XSD.
>
Does anyone have an answer? Thanks.
>
================================================== ======================
>
<xs:element name="characteristics">
<xs:complexType>
<xs:sequence>
<xs:element name="characteristic">
<xs:complexType>
<xs:sequence>
<xs:element name="value" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="value" type="xs:string"
use="required" />
<xs:attribute name="description" type="xs:string"
use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:NMTOKEN"
use="optional" />
<xs:attribute name="values" type="xs:string"
use="optional" />
<xs:attribute name="column" type="xs:NMTOKEN"
use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
>