W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2001

Re: restrictions of a complextype element

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Thu, 21 Jun 2001 10:30:23 +0200
Message-ID: <3B31B09F.3952331@dyomedea.com>
To: xmlschema-dev@w3.org
Eddie Robertsson wrote:
> 
> Not really. To achieve what you try to do you first need to create a global
> simpleType for your base type like this:

You can do it like this, however, instead of extending a global
simpleType that you have created, you can also restrict the xs:string
like David was trying to do:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
  <xs:element name="Test">
    <xs:complexType>
      <xs:simpleContent>
        <xs:restriction base="xs:string">
          <xs:enumeration value="hello world"/>
          <xs:enumeration value="this is me"/>
          <xs:attribute name="myAtt" type="xs:string" use="required"/>
        </xs:restriction>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
</xs:schema>

(the xs:attribute needs to be inside the xs:restrict and not outside
xs:simpleContent as David had written).

Hope this helps.

Eric

-- 
Pour y voir plus clair dans la nebuleuse XML...
                                          http://dyomedea.com/formation/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
http://xsltunit.org      http://4xt.org           http://examplotron.org
------------------------------------------------------------------------
Received on Thursday, 21 June 2001 04:30:36 GMT

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