- From: Mukul Gandhi <gandhi.mukul@gmail.com>
- Date: Thu, 3 Nov 2011 07:28:27 +0530
- To: "Costello, Roger L." <costello@mitre.org>
- Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Roger,
It seems use cases like this become little more natural to be
solved (i.e better semantic modeling of the problem domain XSD type
system) with XSD 1.1. Here's a proposed XSD 1.1 answer for this use
case using the CTA construct,
<xs:element name="title" type="property"/>
<xs:element name="author" type="property"/>
<xs:complexType name="property" type="xs:anyType">
<xs:alternative test="name() = 'title'">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100" />
</xs:restriction>
</xs:simpleType>
</xs:alternative>
<xs:alternative test="name() = 'author'">
<xs:complexType>
<xs:sequence>
<xs:element ref="Person" />
</xs:sequence>
</xs:complexType>
</xs:alternative>
<xs:alternative type="xs:error"/>
</xs:complexType>
On Thu, Nov 3, 2011 at 1:35 AM, Costello, Roger L. <costello@mitre.org> wrote:
> 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>
--
Regards,
Mukul Gandhi
Received on Thursday, 3 November 2011 04:53:22 UTC