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>
Message-ID: <NDBBIOBPAGDGFJAHFCGGMEPGCHAA.davec@progress.com>
> 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.

Dave
Received on Wednesday, 22 August 2001 09:37:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:23 GMT