Re: Question about complexType with unordered child elements with at least one child element

Hi,

> > I need some help.
> > I need a type that allows any order of child elements, every element can
> > appear no more than a single time.
> .../...
> > I need at least one child element.
>
> I don't think you can capture this with W3C XML Schema...
>
> Try another schema language :=) ...

Or a combination of more than one. This would be trivial to do by combining
Schematron with W3C XML Schema. With embedded Schematron that checks the
additional constraint your ApplicationRequest type would be:

 <xsd:complexType name="ApplicationRequest">
  <xsd:annotation>
   <xsd:appinfo>
    <sch:pattern name="At least one one child">
     <sch:rule context="ApplicationRequest">
      <sch:assert test="count(*) &gt;= 1">You must have at least one child
element of the <sch:name/> element.</sch:assert>
     </sch:rule>
    </sch:pattern>
   </xsd:appinfo>
  </xsd:annotation>
                <xsd:all>
                        <xsd:element name="PermissionRequestSet"
type="xsd:string" minOccurs="0"/>
                        <xsd:element name="LocationRequestSet"
type="xsd:string" minOccurs="0"/>
                        <xsd:element name="MapRequestSet" type="xsd:string"
minOccurs="0"/>
                        <xsd:element name="InfoRequestSet" type="xsd:string"
minOccurs="0"/>
                        <xsd:element name="GeoCodeRequestSet"
type="xsd:string" minOccurs="0"/>
                        <xsd:element name="GeoItemsRequestSet"
type="xsd:string" minOccurs="0"/>
                        <xsd:element name="RouteRequestSet" type="xsd:string"
minOccurs="0"/>
                </xsd:all>
 </xsd:complexType>

For more information about embedding Schematron within XML Schema see
http://www.xfront.com/ExtendingSchemas.html.

Cheers,
/Eddie

Received on Tuesday, 26 June 2001 22:52:21 UTC