Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"XSD Choice" for attributes in XSD file

Status
Not open for further replies.

kyru

Programmer
Jan 17, 2009
45
ES
I want to declare the following thing in an XSD file:

Let's suppose we have a <field></field> item. This field can choose between three different types of attributes, but can just have one of them or none. I mean:

<field name_attribute="value">
<field name_attribute2="value">
<field name_attribute3="value">
<field>

Would be ok but:
<field name_attribute="value" name_attribute2="value">
or
<field name_attribute2="value" name_attribute3="value">
wouldn't be right.

I know that with xsd choice you can do that with elements, but I'm not sure if treating those attributes as elements could bring problems in the future as the application I'm doing is right now.

Is there any way to do what I'm telling or the only way is using xsd:choice for elements?



 
>This field can choose between three different types of attributes, but can just have one of them or none.
As a matter of record, within w3c schema, you can make it relatively painlessly only if "none" is excluded. Otherwise, you can also consider using alternative schema such as relax ng and schematron.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top