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

Re: RES: Sequence fixed attributes

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sun, 6 Jan 2002 23:18:58 +0000
Message-ID: <13528302637.20020106231858@jenitennison.com>
To: "Gerson Mizuta Weiss" <weiss@cpqd.com.br>
CC: xmlschema-dev@w3.org
Hi Gerson,

> I would like to know if it is possible to extend a xsd type (like
> xs:string) without having to define global SimpleTypes. For example,
> I have to define many string type attributes, but all of them have
> different lenghts.

You can't *extend* simple types, but you can *restrict* them (which is
what I think you're trying to do), in almost exactly the way that
you've done it - you can have anonymous simple types nested within
xs:attribute elements to specify the type of the particular attribute.
So with:

> <xs:attribute name = "value1" type="xs:string" use="required"/>
> <!-- where the max length is 30
> <xs:attribute name = "value2" type= "xs:string" use="required"/>
> <!-- where the max length is 20
>         ...
> <xs:attribute name = "value3" type= "xs:string" use="required"/>
> <!-- where the max length is 11

You can have:

  <xs:attribute name = "value1" use="required">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:maxLength value="30"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:attribute>

  <xs:attribute name = "value2" use="required">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:maxLength value="20"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:attribute>

And so on.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Sunday, 6 January 2002 18:19:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:26 GMT