W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2003

RE: How to derive from a mixed anyType?

From: Lemmin, Harald <Harald.Lemmin@softwareag.com>
Date: Thu, 17 Apr 2003 11:06:03 +0200
Message-ID: <DFF2AC9E3583D511A21F0008C7E6210606E34C0B@daemsg02.software-ag.de>
To: xmlschema-dev@w3.org

> 
> Given a base type defined thus:
> 
>   <complexType name="AbstractBaseType" abstract="true" mixed="true">
>     <attribute name="id" type="ID" use="optional"/>
>   </complexType>
> 
> The intention was to define a type from which both simpleContent and
> complexContent types could be derived, which may carry an id 
> attribute.  
> 
> 1.  how does one derive an element-only type from it?  I 
> think extension
> leaves the mixed content still there.  does it require a two-step
> restriction to suppress the literal content then extension to add the
> desired element content?  What does this look like?

Yes, restrict the type by setting mixed to false:

  <xs:complexType name = "elementOnly" mixed = "false">
    <xs:complexContent>
      <xs:restriction base = "AbstractBaseType"></xs:restriction>
    </xs:complexContent>
  </xs:complexType>
 
> 2.  how does one derive a simpleContent type whose content 
> has a specified
> simpleType?  

Define the simpleContent type by a local simpleType:

  <xs:complexType name = "simpleContent">
    <xs:simpleContent>
      <xs:restriction base = "AbstractBaseType">
        <xs:simpleType>
          <xs:restriction base = "xs:string"></xs:restriction>
        </xs:simpleType>
      </xs:restriction>
    </xs:simpleContent>
  </xs:complexType> 
Received on Thursday, 17 April 2003 05:06:07 GMT

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