In general, this type of constraint is not available in the Xml Schema.
However, if "bar" is a simple type or a simple content element, your
particular case can be solved with the following XSD:
<xs:element name="top">
<xs:complexType>
<xs:sequence>
<xs:element name="bar" minOccurs="0" type="xs:string"/>
</xs:sequence>
<xs:attribute name="bar" type="xs:anyURI"/>
</xs:complexType>
<xs:unique name="elementORattr">
<xs:selector xpath="."/>
<xs:field xpath="tns:bar|@bar"/>
</xs:unique>
</xs:element>
I used "tns" as the namespace in the xs:field. You'll need to change it to
the prefix you've defined for the target namespace.
--
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
<gisleyt@gmail.com> wrote in message
news:1145951114.632432.310300@t31g2000cwb.googlegr oups.com...[color=blue]
> Is it possibly to specify that I want a either a element or an
> attribute to occur, but not both at the same time?
>
> <xs:complexType name="foo">
> <xs:sequence>
> <xs:element minOccurs="0" ref="bar"/>
> </xs:sequence>
> <xs:attribute name="bar" default="" type="xs:anyURI"/>
> </xs:complexType>
>
> In this complexType I don't want both the element "bar" and the
> attribute "bar" to be present, only one of them. Can I express this in
> any way in xsd?
>
> -Gisle-
>[/color]