Re: How to choice the attribute group for element?

I'm afraid that currently you can't do what you want to do in XSD 1.0.  The 
still being developed XSD 1.1 will allow you to do what you want to do via 
xs:assert elements.

With regard to your example schema, this is not valid because it violates 
XSD's Unique Particle Attribution (UPA) Constraint.  In other words, it 
defines a schema such that when parsing an XML instance and encountering an 
element called "x" it is not possible for the parser to tell whether it 
refers to the first "x" definition or the second "x" definition.

The Relax NG schema language doesn't impose such constraints on a parser and 
I believe the equivalent form of your schema expressed in Relax NG would be 
valid.

HTH,

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using XML C++
data binding to convert XSD schemas to C++ classes.
Visit http://www.xmldatabinding.net or http://www.xml2cpp.com
for more info
----- Original Message ----- 
From: "bacoo_zh" <bacoo_zh@163.com>
To: "xmlschema-dev" <xmlschema-dev@w3.org>
Sent: Saturday, June 06, 2009 5:55 PM
Subject: How to choice the attribute group for element?


Hi,
This is my first time to have a discussion here. I'm new to XML Schema.
Now I want to define an element with three attributes: A, B and C. However, 
I don't want the three attributes occur simultaneously.
I need A and B occur simultaneously, or only C occurs singlely.

<x A="a" B="b"/>
or
<x C="c">

How to do this?
I use 'choic' to implement this as follows, but it don't work.
<xs:choice maxOccurs="unbounded">
      <xs:element name="x"  type="xs:string">
<xs:complexType>
<xs:attribute name="A" type="xs:string"/>
<xs:attribute name="B" type="xs:string"/>
</xs:complexType>
      </xs:element>
      <xs:element name="x"  type="xs:string">
<xs:complexType>
<xs:attribute name="C" type="xs:string"/>
</xs:complexType>
      </xs:element>
<£¯xs:choice>
By the way, after goooooogling, I found that the code above is right in the 
old XML Schema criteria, but nowadays I can't use it any more and the XMLSpy 
software will report errors with the code above. Is there anyone that know 
about the related information?
It has bothered me several days. I'll appreciate your help sincerely. 

Received on Tuesday, 9 June 2009 08:32:06 UTC