W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2002

Question about complexContent restriction

From: Brenda Bell <bbell@juicesoftware.com>
Date: Sat, 20 Jul 2002 20:54:05 -0400
Message-ID: <846B0B02E1B78B49B678EDCC00EB2962FB4FA7@mail01.ent.juice.com>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
I'm trying really hard to understand this schema stuff, but the examples I'm
finding are making it difficult :)

I found the following example:

<xs:complexType name="address">
  <xs:sequence>
    <xs:element name="street" type="xs:string" />
    <xs:element name="city" type="xs:string" />
    <xs:element name="zipcode" type="xs:integer" />
    <xs:element name="country" type="xs:string" />
  </xs:sequence>
</xs:complexType>

<xs:complexType name="USAddress">
  <xs:complexContent>
    <xs:restriction base="address">
      <xs:sequence>
        <xs:element name="street" type="xs:string" />
        <xs:element name="city" type="xs:string" />
        <xs:element name="zipcode" type="xs:integer" />
        <xs:element name="country" type="xs:string" fixed="US" />
      </xs:sequence>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>

It appears that USAddress does nothing more than redefine address with the
additional restriction that country's value be fixed to "US".  Seems I could
have gotten the same results by defining complexContent without the
restriction so I'm thinking there must be more to a restriction that what
this example shows.

What am I missing?  Better yet, I'd love to see other examples of where you
would actually use a restriction to see if I can figure it out for myself.

Brenda Bell
Sr. Software Architect
Juice Software, Inc.
Phone: 603.428.3994
Cell:  603.494.8206
Fax:   603.428.8713
Email: bbell@juicesoftware.com
MSN:   bbell@theotherbell.com
Received on Saturday, 20 July 2002 20:56:00 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC