Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: How to choice the attribute group for element?

From: "Michael Kay" <mike@--------.--->
To: "'bacoo'" <bacoo_zh@---.--->, "'xmlschema-dev'" <xmlschema-dev@--.--->
Date: 6/9/2009 8:40:00 AM
> 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.

I'm afraid it's a well-known limitation of XSD 1.0 that you can't do this.
It always surprises newcomers, but I'm afraid it's true. The limitation
disappears in XSD 1.1, but that's still "on the drawing board" and not yet
supported in most products.

If you want to try it out, Saxon-SA 9.1 does support the new feature of
"conditional type assignment". However, the "mainstream" solution to this
kind of requirement is to supplement XSD validation with another validation
pass using Schematron, which allows testing your document against arbitrary
predicates.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


> 
> <x A="a" B="b"/>
> or
> <x C="c">
>  	 EG320270420CN
> 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.
> 
> 
> 
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent