Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - An element with more than one possible type [Thread Next] Re: An element with more than one possible typeTo: pau carre <pau.carre@-----.---> Date: 2/3/2007 11:49:00 AM Hi, pau carre <pau.carre@g...> writes: > <items> > <item name = "pen" color ="22"> > <item name = "pencil" smoothness = "10" > > </items> > > It is to say, if name is "pen" , then use the "color" attribute. > When name is "pencil" then use "smoothness" attribute. You won't be able to do this in XML Schema. The closest you can get is with xsi:type-based dynamic typing, e.g., <items> <item xsi:type="pen" color ="22"/> <item xsi:type="pencil" smoothness = "10"/> </items> To achieve this you would define a base type for item and then extend it to "pen" and "pencil". If I were you, I would just get rid of the extra naming layer and simply have something like this: <items> <pen color ="22"/> <pencil smoothness = "10"/> </items> You can still keep this design open-ended (i.e., you can add more item types without modifying the items definition) with substitution groups. hth, -boris -- Boris Kolpackov Code Synthesis Tools CC http://www.codesynthesis.com Open-Source, Cross-Platform C++ XML Data Binding | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
