OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
ANN: Portable Data Component -- time interval (start/end orstart/duration)

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]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS