Bug #2054
closeduse of <any> in additionalMetadata is invalid
0%
Description
Johnoel from Hawaii also reported the same problem which Margaret reported
earlier while using latest version of XMLSpy2005 or oXygen to parse XML Schema
The error from oXygen is:
E cos-nonambig: "":describes and WC[##any] (or elements from their substitution
group) violate "Unique Particle Attribution". During validation against this
schema, ambiguity would be created for those two particles. eml.xsd 246:27
More information about this can be found here: http://www.w3.org/TR/2000/WD-
xmlschema-1-20000407/#non-ambig
Following text from the above page descibes what is happening:
We say that two non-group particles overlap if
- One is a wildcard and the other an element declaration, and the
{target namespace}
<http://www.w3.org/TR/2000/WD-xmlschema-1-20000407/#e-target_namespace>
of the element declaration, or of any member of its equivalence
class <http://www.w3.org/TR/2000/WD-xmlschema-1-20000407/#key-eq>,
is schema-valid with respect to the {namespace constraint}
<http://www.w3.org/TR/2000/WD-xmlschema-1-20000407/#namespace_constraint>
of the wildcard.
So the schema that we have in EML is:
<xs:complexType>
<xs:sequence>
<xs:element name="describes" type="xs:string" minOccurs="0"
maxOccurs="unbounded">
</xs:element>
<xs:any processContents="lax">
</xs:any>
</xs:sequence>
<xs:attribute name="describes" type="xs:string" use="optional"/>
<xs:attribute name="id" type="res:IDType" use="optional"/>
</xs:complexType>
This is a problem because <xs:any> is a wildcard and could be anything
including <describes> itself. In particular a document which has following text
can confuse the parser
<additionalMetadata>
<describes>1</describes>
<describes>2</describes>
<describes>3</describes>
</additionalMetadata>
So here the parser doesnt know if the last <describes> tag should be
considered as <xs:any> or not.
(Though I think that as only one <xs:any> is possible, the last tag should be
takes as <xs:any> by default. But I must be missing something as both oXygen
and XMLSpy complain about this)
I was able to correct this error by doing the following
1. <describes> tag is required and can occur only once
<xs:complexType>
<xs:sequence>
<xs:element name="describes" type="xs:string">
</xs:element>
<xs:any processContents="lax">
</xs:any>
</xs:sequence>
<xs:attribute name="id" type="res:IDType" use="optional"/>
</xs:complexType>
2. describes is an attribute of additionalMetadata
<xs:complexType>
<xs:sequence>
<xs:any processContents="lax">
</xs:any>
</xs:sequence>
<xs:attribute name="describes" type="xs:string" use="optional"/>
<xs:attribute name="id" type="res:IDType" use="optional"/>
</xs:complexType>
3. <xs:any> is inside the <describes> tag
<xs:complexType>
<xs:sequence>
<xs:element name="describes" type="xs:string" minOccurs="0"
maxOccurs="1">
<xs:sequence>
<xs:any processContents="lax">
</xs:any>
</xs:sequence>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="res:IDType" use="optional"/>
</xs:complexType>
I think the first one would be the best in terms of minimum change to the
schema.
Files
Related issues