Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - XML Schema question: attribute xor content [Thread Next] Re: XML Schema question: attribute xor contentTo: NULL Date: 8/13/2009 12:29:00 PM Jun wrote: > I have a simple (I hope) question about XML Schema. The problem is > that I want to declare an element that has either an attribute or some > content, but not both, e.g.: > > <myelement value="stuff"/> > > xor, > > <myelement>stuff</myelement> > > Is there a way to this with XML Schema? I don't see a way to specify that with the W3C XML schema language but Relax NG can do that: <element name="root" xmlns="http://relaxng.org/ns/structure/1.0"> <zeroOrMore> <element name="myelement"> <choice> <text/> <attribute name="value"> <text/> </attribute> </choice> </element> </zeroOrMore> </element> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
