W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2007

Expressing relations between types

From: Eric MALENFANT <Eric.Malenfant@sagem-interstar.com>
Date: Fri, 30 Nov 2007 10:23:23 -0500
Message-ID: <F660559FAA5FCD46B38F53152D092E2894354B@ares.INTERSTARINC.COM>
To: <xmlschema-dev@w3.org>

Consider an "Entry" type like this one:
  <xs:complexType name="Entry">
      <xs:element name="Received" type="xs:dateTime" />
      <xs:element name="Subject" type="xs:string" />
      <xs:element name="IsViewed" type="xs:boolean" />
      <xs:element name="Pages" type="xs:unsignedInt" />
Note that, in the real case, an Entry would have more elements that
all being of dateTime, string, boolean or unsignedInt types.  

A webservice method "findEntries" will return an array of Entry, based
a filtering predicate passed in by its client. The "straightforward"
of such an EntryPredicate could be:
  <xs:complexType name="EntryPredicate">
      <xs:element minOccurs="0" name="Received" type="dateTimeRange" />
      <xs:element minOccurs="0" name="Subject:" type="xs:string" />
      <xs:element minOccurs="0" name="IsViewed" type="xs:boolean" />
      <xs:element minOccurs="0" name="Pages" type="unsignedIntRange" />
  <xs:complexType name="dateTimeRange">
      <xs:element minOccurs="0" name="Begin" type="xs:dateTime" />
      <xs:element minOccurs="0" name="End" type="xs:dateTime" />
  <xs:complexType name="unsignedIntRange">
      <xs:element name="Begin" type="xs:unsignedInt" />
      <xs:element name="End" type="xs:unsignedInt" />
For example, the client looking for unviewed entries having two Pages or
would pass in an EntryPredicate like:
As you can see, the definition of EntryPredicate is closely tied to that
of Entry,
and it seems to me that there is a lot of repetition between Entry and

I am thus wondering if there is a better way to define "related" types
like this.
For example, is there a way to express the definition of EntryPredicate
by saying
something like "this is the same thing than an Entry, replacing dateTime
by dateTimeRange,
unsingedInt by unsignedIntRange"?

In case this is not obvious: I have virtually no experience with XML
so any pointers are appreciated.
Received on Friday, 30 November 2007 23:47:33 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:13 UTC