[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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>
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 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.