Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: An element with more than one possible type

From: Boris Kolpackov <boris@-------------.--->
To: 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


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