Re: name conflict

Hi Andrea,

> i have a problem with name conflict, i do not understand if this
> schema document is valid or not:

I'm afraid that it isn't valid. The problems are where you identified
them:

> <xs:sequence>
>   <xs:element name="d">
>     <xs:complexType />
>   </xs:element>
>   <xs:element name="a" type="xs:string"/>
>   <xs:choice>
>     <xs:element name="b" type="xs:string"/>
>     <xs:element name="a" type="xs:byte"/> <!-- is it legal ? -->
>     <xs:element name="a" type="xs:byte"/>
>   </xs:choice>
>   <xs:sequence>
>     <xs:element name="a"> <!-- and this ? -->
>       <xs:complexType />
>     </xs:element>
>   </xs:sequence>
> </xs:sequence>

Within any xs:sequence or xs:choice or xs:all (i.e. any model group),
all the elements, at whatever level, that have the same name *must*
have the same type. In the above, you have three different types for
the a elements:

  <xs:element name="a" type="xs:string" />
  <xs:element name="a" type="xs:byte" />
  <xs:element name="a"><xs:complexType /></xs:element>

This isn't allowed. You could alternatively declare all the a elements
as being of the type xs:anyType (which is the default if you don't
specify what type they are) -- that will enable them to hold strings,
bytes or nothing at all without any problems. But you can't say that
particular ones are strings, bytes or empty.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 28 February 2002 13:42:47 UTC