Actually, MSXML 4.0 complains about this schema. It says that elements with the same name and in the same scope have to be of the same type. In this case, type C2 contains two A elements of different types, hence the schema is invalid.
 
Strangely, I too couldn't find anything in the XML Schema spec. about this.
 
Alex
 

---------------------------------------------------------------------------
Aleksandar Milanovic     | Privileged or confidential information may be
Product Manager/Engineer | contained in this message. If this message was
Cartagena Project        | not intended for you,  destroy it and notify us
Galdos Systems Inc.      | immediately. Opinions, conclusions,
Tel: (604) 484-2750      | recommendations, and other information presented
Fax: (604) 484-2755      | in this message are not given or necessarily
[EMAIL PROTECTED] | endorsed by my employer or firm.

-----Original Message-----
From: Bob Schloss [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 31, 2002 10:15 AM
To: [EMAIL PROTECTED]
Subject: Re: Allowable schema representations

W3C XML Schema language permits different content models for elements with the same name, as long as the validator can unambiguously determine which content model applies. Your examples are legal.

Bob Schloss
XML/XSL Transformational Systems
IBM Thomas J. Watson Research Center
Yorktown Heights, New York, USA

Please respond to [EMAIL PROTECTED]

To: [EMAIL PROTECTED]
cc:
Subject: Allowable schema representations



If I define an XML schema as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- strange.xsd -->
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"

<xsd:complexType name="C1">
<xsd:sequence>
    <xsd:element name="A" type="xsd:string"/>
    </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="C2">
    <xsd:sequence>
    <xsd:element name="A" type="C1"/>
    <xsd:element name="A" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="A" type="C2"/>

</xsd:schema>


then an instance document looks like

<?xml version="1.0" encoding="UTF-8"?>
<!-- strange.xml -->
<A xmlns="
http://localhost/strange"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://localhost/strange strange.xsd">
<A>

<A>foo</A>
</A>
<A>bar</A>

</A>


Is there anything inherently wrong with having an "A" element used in
many different ways? Xerces will certainly validate the document OK, and
I couldn't find anything in the xml-schema spec that invalidates this.
It looks strange to me, as I don't think you could have defined this
structure using a DTD. Does anyone have a view on this?

cheers

Loz


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to