W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2003

Explanation of xs:restriction and xs:extension

From: Jochen Wiedmann <joe@ispsoft.de>
Date: Thu, 01 May 2003 18:39:29 +0200 (CEST)
To: xmlschema-dev@w3.org
Message-ID: <1051807169.3eb14dc1881e9@webmail.LF.net>


can anyone point me to a more readable explanation of
xs:restriction and xs:extension in complex elements?
I really do not understand the specification. In particular
I would like to have answers to the following questions:

Suggest the following groups "group", "realgroup", and
"groupRef" from XML schema. (See below.)

1.) The group "group" uses a group ("particle") as the content
    model. The "realGroup" has a "choice" with some elements from

    - Does the "choice" from "realGroup" need to match the "choice"
      of particle? Or would it be possible to use a "sequence" in

    - Obviously the relation between the elements in "realGroup" and
      the elements in "particle" is by name. Is the relation always
      by name? If so, are there other possible relations, for example,
      by order? Are the element names unique? In other words, can I
      restrict a type with the content model "either a, followed by b,
      or c, followed by b"? (Note that the element name b is not unique.)

2.) The group "group" is extending "xs:annotated". The latter specifies
    an element "id". The attribute "id" from "xs:annotated" isn't
    mentioned. However, a group may surely have an ID. In other words:
    An attribute which is missing in the restriction, is inherited

3.) As a conclusion: The group "realGroup" has the same attributes
    than "group": "ref", "name", "minOccurs", and "maxOccurs". But
    "groupRef" requires "ref" and must not have "name" attribute.

Kind regards,


  <xs:complexType name="group" abstract="true">
      <xs:extension base="xs:annotated">
        <xs:group ref="xs:particle" minOccurs="0" maxOccurs="unbounded"/>
        <xs:attributeGroup ref="xs:defRef">
        <xs:attributeGroup ref="xs:occurs">

  <xs:complexType name="realGroup">
      <xs:restriction base="xs:group">
          <xs:element ref="xs:annotation" minOccurs="0"/>
          <xs:choice minOccurs="0" maxOccurs="1">
            <xs:element ref="xs:all"/>
            <xs:element ref="xs:choice"/>
            <xs:element ref="xs:sequence"/>

  <xs:complexType name="groupRef">
       <xs:restriction base="xs:realGroup">
           <xs:element ref="xs:annotation" minOccurs="0"/>
         <xs:attribute name="ref" use="required" type="xs:QName"/>
         <xs:attribute name="name" use="prohibited"/>
Received on Thursday, 1 May 2003 12:39:36 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:01 UTC