RE: elements with the same name

> 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 UTC