[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Best Practice for this problem?
- From: Paul Spencer <paul.spencer@boynings.co.uk>
- To: Xml-Dev <xml-dev@lists.xml.org>
- Date: Mon, 19 Mar 2001 12:33:57 +0000
I have recently been asked to look at a schema, of which this is a part:
<xsd:choice>
<xsd:annotation>
<xsd:documentation>At least one of Town, County and
Locality</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:element name="Town" type="bs7666:TownType"/>
<xsd:element name="Locality" type="bs7666:LocalityType"/>
<xsd:element name="County" type="bs7666:CountyType"/>
</xsd:choice>
<xsd:sequence>
<xsd:element name="Town" type="bs7666:TownType"/>
<xsd:element name="Locality" type="bs7666:LocalityType"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="Town" type="bs7666:TownType"/>
<xsd:element name="County" type="bs7666:CountyType"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="Locality" type="bs7666:LocalityType"/>
<xsd:element name="County" type="bs7666:CountyType"/>
</xsd:sequence>
<xsd:sequence>
<xsd:element name="Town" type="bs7666:TownType"/>
<xsd:element name="Locality" type="bs7666:LocalityType"/>
<xsd:element name="County" type="bs7666:CountyType"/>
</xsd:sequence>
</xsd:choice>
The intention is clear - at least one of the three elements <Town>,
<Locality>, <County>, but each must not appear more than once.
I believe the format to be non-compliant with XML Schema since each of the
three elements has multiple definitions within the same scope. XML Authority
2.1 agrees with me, XML Spy 3.5 does not.
If I am right, there are two choices:
1. Define the three elements globally, then reference them as required. This
loses the benefit of a local definition within the complex data type.
2. Define the elements as at the start of the example:
<xsd:choice>
<xsd:element name="Town" type="bs7666:TownType"/>
<xsd:element name="Locality" type="bs7666:LocalityType"/>
<xsd:element name="County" type="bs7666:CountyType"/>
</xsd:choice>
Then access by reference from there. For example:
<xsd:sequence>
<xsd:element ref="Town"/>
<xsd:element ref="Locality"/>
</xsd:sequence>
I have never seen an example that uses "ref=" pointing to a locally scoped
definition. Is this allowed?
Any thoughts?
Regards
Paul Spencer