W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2001

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

From: Eddie Robertsson <eddie@allette.com.au>
Date: Wed, 27 Jun 2001 12:52:05 +1000
Message-ID: <3B394A55.2BA23686@allette.com.au>
To: vdv@dyomedea.com
CC: xmlschema-dev@w3.org

> > 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">
    <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>
                        <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"
                        <xsd:element name="InfoRequestSet" type="xsd:string"
                        <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"

For more information about embedding Schematron within XML Schema see

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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:51 UTC