Expressing relations between types

Consider an "Entry" type like this one:
  <xs:complexType name="Entry">
    <xs:sequence>
      <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" />
    </xs:sequence>
  </xs:complexType>
  
Note that, in the real case, an Entry would have more elements that
this, 
all being of dateTime, string, boolean or unsignedInt types.  

A webservice method "findEntries" will return an array of Entry, based
on 
a filtering predicate passed in by its client. The "straightforward"
defintion
of such an EntryPredicate could be:
  <xs:complexType name="EntryPredicate">
    <xs:sequence>
      <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:sequence>
  </xs:complexType>
  <xs:complexType name="dateTimeRange">
    <xs:sequence>
      <xs:element minOccurs="0" name="Begin" type="xs:dateTime" />
      <xs:element minOccurs="0" name="End" type="xs:dateTime" />
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="unsignedIntRange">
    <xs:sequence>
      <xs:element name="Begin" type="xs:unsignedInt" />
      <xs:element name="End" type="xs:unsignedInt" />
    </xs:sequence>
  </xs:complexType>
  
For example, the client looking for unviewed entries having two Pages or
more
would pass in an EntryPredicate like:
  <EntryPredicate>
    <IsViewed>false</IsViewed>
    <Pages>
      <Begin>2</Begin>
    </Pages>    
  </EntryPredicate>
  
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
EntryPredicate.

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
schemas,
so any pointers are appreciated.

Received on Friday, 30 November 2007 23:47:33 UTC