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

ANN: Portable Data Component -- time interval (start/end orstart/durati

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Sat, 23 Apr 2011 10:36:02 -0400

ANN: Portable Data Component -- time interval  (start/end orstart/durati
Hi Folks,

This is an extension of the start/end portable data component. 

A time interval may be expressed using either of these:

      - start and end values, or
      - start and duration values.

Here are examples using start/duration. 

Example #1

The class starts on May 3, 2011 at 8am and runs for 8 hours:


Example #2

My vacation begins June 22, 2011 and is for 3 days:


The constraints on the start/end values are those described earlier. 

There is one constraint on the start/duration values: the duration must not be a negative value. 

Determining that duration is not a negative value is not straightforward. One would think that this XPath expression would do the job:

  	xs:duration(duration) gt xs:duration("P0Y")

However, that is not correct. It will generate this error:

    	xs:duration is not an ordered type

Instead, what is required is to treat duration as a string and check that the string starts with the letter 'P' (i.e., not the letter '-'):

	starts-with(duration, 'P')

Here is the time-interval portable data component:

    <xs:complexType name="time-interval">
            <xs:element name="start">
                    <xs:union memberTypes="xs:date xs:time 
                                                                          xs:dateTime" />
                <xs:element name="end" minOccurs="0">
                        <xs:union memberTypes="xs:date xs:time 
                                                                              xs:dateTime" />
                <xs:element name="duration" type="xs:duration" />
        <xs:assert test="if (exists(end)) then 
                                                if (start castable as xs:dateTime) then
                                                        xs:dateTime(end) gt xs:dateTime(start)
                                               else if (start castable as xs:date) then
                                                       xs:date(end) gt xs:date(start)
                                               else if (start castable as xs:time) then
                                                      xs:time(end) gt xs:time(start)
                                               else true()
                                       else if (exists(duration)) then
                                              starts-with(duration, 'P')
                                      else true()" />

A summary of all our discussions on Portable Data Components may be found here:



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.