Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - Re: extending schema >Thread Next - RE: Determinization in case of ambiguity or Should XML validators report on schemas that violate the UPA constraint? Determinization in case of ambiguity or Should XML validators report on schemas that violate the UPA constraint?To: <xmlschema-dev@--.---> Date: 4/15/2007 5:57:00 PM Hello, In the following example schema the element <b/> can appear either as part of a sequence model group or as part of a choice model group or as an all model group. This means that the instance does not follow the Unique Particle Attribution Constraint (see: "Section 3.8.6: Constraints on Model Group Schema Components " and Appendix H in "XML Schema Part 1: Structures Second Edition, W3C Proposed Edited Recommendation"). <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="" xmlns="foo"> <xsd:element name="a"> <xsd:complexType> <xsd:sequence minOccurs="0" maxOccurs="2"> <xsd:sequence minOccurs="0" maxOccurs="2"> <xsd:element ref="b" minOccurs="0" maxOccurs="2"/> <xsd:element ref="c" minOccurs="0" maxOccurs="2"/> </xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="2"> <xsd:element ref="b" minOccurs="0" maxOccurs="2"/> <xsd:element ref="d" minOccurs="0" maxOccurs="2"/> </xsd:choice> <xsd:all minOccurs="0" maxOccurs="1"> <xsd:element ref="e" minOccurs="0" maxOccurs="2"/> <xsd:element ref="b" minOccurs="0" maxOccurs="2"/> </xsd:all> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="b"> <xsd:complexType/> </xsd:element> <xsd:element name="c"> <xsd:complexType/> </xsd:element> <xsd:element name="d"> <xsd:complexType/> </xsd:element> <xsd:element name="e"> <xsd:complexType/> </xsd:element> </xsd:schema> My question is: should the following example be valid against the schema or not valid? <a> <b/><c/><b/> </a> I see that different XML validators behave differently on this example. However, I did not see them report an error in the schema. Now, please consider the following schema: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="bar" xmlns="foo"> <xsd:element name="a"> <xsd:complexType> <xsd:sequence> <xsd:sequence minOccurs="0"> <xsd:element name="b"> <xsd:complexType/> </xsd:element> </xsd:sequence> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Instance: <a/> Is it valid? See, the element b might not appear and that's OK if you ask the inner sequence but the outer sequence needs to "happen" once (the minOccurs="1" is implied). So, how should I read this? Is the above single <a/> element instance valid or not with this schema? Is such a schema legal or not? If the schema is not legal, must a schema processor report an error? Thanks. Shlomo. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
