Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSD - one of 2 attributes is required?

Tags:

xsd

Is there a way to specify that one of 2 attributes is required in XSD?

for example, I have a definition like this:

<xs:attribute name="Name" type="xs:string" use="optional" /> <xs:attribute name="Id" type="xs:string" use="optional" /> 

I want to be able to define that at least one of these is required. Is that possible?

like image 463
user92454 Avatar asked Apr 18 '09 07:04

user92454


People also ask

How do you make attributes mandatory in XSD?

Attributes are either optional or mandatory (by default they are optional). The "use" property in the XSD definition is used to specify if the attribute is optional or mandatory. To specify that an attribute must be present, use="required" (Note: use may also be set to "prohibited", but we'll come to that later).

What is minOccurs and maxOccurs in XSD?

The minOccurs attribute specifies the minimum number of times that the element can occur. It can have a value of 0 or any positive integer. The maxOccurs attribute specifies the maximum number of times that the element can occur.

How do you define an element attribute in XSD?

An attribute provides extra information within an element. Attributes are defined within an XSD as follows, having name and type properties. An Attribute can appear 0 or 1 times within a given element in the XML document. Attributes are either optional or mandatory (by default the are optional).

Which one of the following indicators define that either one of the child element must occur within the element select one any choice all sequence?

Occurence Indicators minOccurs − Child element must occur minOccurs number of times.


1 Answers

No, I don't think you can do that with attributes. You could wrap two <xs:element> into a <xs:choice> - but for attributes, there's no equivalent construct, I'm afraid.

like image 191
marc_s Avatar answered Sep 20 '22 19:09

marc_s