- From: Dare Obasanjo <dareo@microsoft.com>
- Date: Thu, 10 Apr 2003 11:18:30 -0700
- To: "Pradeep Bollineni" <pradeepbollineni@hotmail.com>, <xmlschema-dev@w3.org>
Elements declarations with the same name must have the same type. The second schema fragment with elementFormDefault set to qualified is invalid. ________________________________ From: Pradeep Bollineni [mailto:pradeepbollineni@hotmail.com] Sent: Thu 4/10/2003 11:00 AM To: xmlschema-dev@w3.org Subject: Is defining a local element and element ref with same name in complexType valid Hi, I have a doubt regarding how this would work. Consider the following schema: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified" targetNamespace="http://tns" xmlns="http://tns"> <xs:element name="Elem1" type="CT1"/> <xs:complexType name="CT1"> <xs:sequence> <xs:element name="Elem0" type="xs:string"/> <xs:element ref="Elem0"/> </xs:sequence> </xs:complexType> <xs:element name="Elem0" type="xs:int/"> As elementFormDefault is unqualified we could have a schema instance as follows: <n:Elem1 xmlns:n="http://tns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tns C:\tmp\xsd\complexContent_extension.xsd"> <Elem0>String</Elem0> <n:Elem0> 10 </n:Elem0> </n:Elem1> which is fine as the first Elem0 belongs to no namespace and the second to " namespace http://tns". The problem is when elemenFormDefault is qualified. In which case we can have an instance as follows: <n:Elem1 xmlns:n="http://tns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tns C:\tmp\xsd\complexContent_extension.xsd"> <n:Elem0>String</n:Elem0> <n:Elem0> 10 </n:Elem0> </n:Elem1> or <Elem1 xmlns="http://tns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tns C:\tmp\xsd\complexContent_extension.xsd"> <Elem0>String</Elem0> <Elem0> 10 </Elem0> </Elem1> Will this be validated correctly by the parsers as we have two elements with the same name belonging to the same namespace? It might become even more difficult if complexType CT1 has "all" as its model group instead of "sequence". Is this schema and instance (with elementFormDefault as qualified) valid? Thanks Pradeep ________________________________ MSN 8 helps ELIMINATE E-MAIL VIRUSES. <http://g.msn.com/8HMJENUS/2743> Get 2 months FREE*.
Received on Thursday, 10 April 2003 14:18:39 UTC