|
[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: An element with more than one possible type
From: Boris Kolpackov <boris@codesynthesis.com>
Date: Sat, 3 Feb 2007 09:48:56 +0200 To: pau carre <pau.carre@gmail.com> Cc: xmlschema-dev@w3.org Message-ID: <20070203074856.GA16028@karelia> Hi, pau carre <pau.carre@gmail.com> 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 BindingReceived on Saturday, 3 February 2007 07:59:13 GMT |
Subscribe in XML format
|






