Re: RES: Sequence fixed attributes

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 UTC