How to define a complexType so that derived types can have simple content or complex content?

Hi Folks,

I would like to associate this title element with a complexType named property:

<title>The Implementation of Functional Programming Languages</title>

Notice that this "property element" has simple content.

I would like to associate this author element with the same property complexType:

    <author>
        <Person>
            <name>Simon L. Peyton Jones</name>
        </Person>
    </author>

Observe that this property element has complex content.

Thus, there are property elements with simple content and property elements with complex content.

How do I define a property complexType such that it can be restricted to simpleContent and extended to complexContent?

The following works, but I am not happy with it because it uses mixed="true" which I do not want. The <author> element has mixed content. Is there a way to implement this without requiring some property elements to have mixed content?   /Roger

    <xs:complexType name="property" abstract="true" mixed="true" />

    <xs:element name="title" type="titleType" />
    
    <xs:complexType name="titleType">
        <xs:simpleContent>
            <xs:restriction base="property">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:maxLength value="100" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:restriction>
        </xs:simpleContent>
    </xs:complexType>

    <xs:element name="author" type="authorType" />
    
    <xs:complexType name="authorType" mixed="true">
        <xs:complexContent>
            <xs:extension base="property">
                <xs:sequence>
                    <xs:element ref="Person" />
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

Received on Wednesday, 2 November 2011 20:08:51 UTC