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:restriction base="xs:string">
        <xs:maxLength value="30"/>

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

And so on.



Jeni Tennison
Received on Sunday, 6 January 2002 18:19:00 UTC

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