W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2001

RE: elements with the same name

From: David E. Cleary <davec@progress.com>
Date: Wed, 22 Aug 2001 09:37:33 -0400
To: "Wendy Lam" <bigangellover@yahoo.com>, <xmlschema-dev@w3.org>
> I've been trying to create a schema that can validate
> the following xml.
> <Address type="US">
>   <Street>12345 main street</Street>
>   <City>JoeTown</City>
>   <Zip>2456</Zip>
> </Address>
> <Address type="China">
>   <Street>12344 lo pai street</Street>
>   <City>...</City>
>   <Province>..</Province>
> </Address>
> There is one tag name <Address>, but based on its
> attribute value of "type", the elements inside of
> <Address> varies.

Instead of using your own type attribute, use the Schema xsi:type attribute.
In an example I'm using in a presentation I am doing, I create an abstract
type called Address that contains elements that are common across all
addresses. I then create extensions that include the local specific stuff.
The element that contains an address uses address in it's content model. The
instance then contains an xsi:type attribute signifying what type of address
it is.

Received on Wednesday, 22 August 2001 09:37:37 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:52 UTC