469,649 Members | 1,177 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,649 developers. It's quick & easy.

usage of "Choice" Compositor with Attributes/attribute

I want an element that must have either attribute A or B.
<Thing1 A="aaa"/> <Thing1 B="bbb"/>
I want to enforce this in my schema . If A and B were
elements, I could use choice.
<xs:attribute name="A"/>
<xs:attribute name="B"/>
<xs:element name="Thing1">
<xs:complexType>
<xs:choice >
<xs:element ref="A"/>
<xs:element ref="B"/>
</xs:choice>
</xs:complexType>
</xs:element>
But choice only works for elements, and I am stuck.
Is there a way to do "choice" for attributes?
And if so, how about for attributeGroups too?
Making both attributes optional would accept valid input
but not reject all invalid input. I am hoping for better.
Thanks!

Oct 26 '05 #1
3 1416
No, XSD does not support this.

--
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
<ko**************@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I want an element that must have either attribute A or B.
<Thing1 A="aaa"/> <Thing1 B="bbb"/>
I want to enforce this in my schema . If A and B were
elements, I could use choice.
<xs:attribute name="A"/>
<xs:attribute name="B"/>
<xs:element name="Thing1">
<xs:complexType>
<xs:choice >
<xs:element ref="A"/>
<xs:element ref="B"/>
</xs:choice>
</xs:complexType>
</xs:element>
But choice only works for elements, and I am stuck.
Is there a way to do "choice" for attributes?
And if so, how about for attributeGroups too?
Making both attributes optional would accept valid input
but not reject all invalid input. I am hoping for better.
Thanks!

Oct 26 '05 #2
Stan Kitsis [MSFT] wrote:
No, XSD does not support this.


SGML does :-)
Well, sorta.

///Peter

Oct 26 '05 #3
Thnx guys for your response :)

Oct 28 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

145 posts views Thread by Sidney Cadot | last post: by
37 posts views Thread by Jan Wagner | last post: by
3 posts views Thread by Sebastian Stein | last post: by
2 posts views Thread by puffy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.