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.
Not really. See comment below.
This is not legal in W3C XML Schema. In order to have two elements with the same name in the same content model they also _must_ have the same type. This constraint is violated in the above type.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"
targetNamespace="http://localhost/strange" xmlns="http://localhost/strange" elementFormDefault="qualified">
<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"/>
The spec reads [1]:
*"Schema Component Constraint: Element Declarations Consistent*
If the {particles} <http://www.w3.org/TR/xmlschema-1/#particles> contains, either directly, indirectly (that is, within the {particles} <http://www.w3.org/TR/xmlschema-1/#particles> of a contained model group, recursively) or �implicitly� <http://www.w3.org/TR/xmlschema-1/#key-impl-cont> two or more element declaration particles with the same {name} <http://www.w3.org/TR/xmlschema-1/#e-name> and {target namespace} <http://www.w3.org/TR/xmlschema-1/#e-target_namespace>, then all their type definitions must be the same top-level definition, that is, *all* of the following must be true:
1 all their {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>s must have a non-�absent� <http://www.w3.org/TR/xmlschema-1/#key-null> name.
2 all their {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>s must have the same name.
3 all their {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>s must have the same target namespace."
Cheers, /Eddie
Thanks for pointing that out. I've included a second example at the end of this message. My reading of the constraint you pointed out makes me believe it is ok. IBM's SQLC tool (thanks Bob) validates it OK. Would you agree with that reading?
Also should a raise a bug against xerces, or has someone already taken care of that?
thanks, again, for your help.
Loz
<?xml version="1.0" encoding="UTF-8"?> <!-- strange.xsd --> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost/strange" xmlns="http://localhost/strange" elementFormDefault="qualified"> <xsd:complexType name="C1"> <xsd:sequence> <xsd:element name="A" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:element name="A" type="C1"/> </xsd:schema>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
