XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
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]
How to represent data that changes over time (time-varying data,i.e., temporal data)

Hi Folks,

Do you have data that changes over time? Below is one way of dealing with time-varying data.

Example: A Book has a Title, Author, Binding (hardcover or softcover), and Cost. The latter two properties vary over time. In 1970 the book had these values:

<Book>
   
<Title>Illusions</Title>
   
<Author>Richard Bach</Author>
   
<!-- Time-varying properties -->
   
<Binding>hardcover</Binding>
   
<Cost>$14.95</Cost>
</Book>

 

An event is a change of one or more of Book’s time-varying properties. A state is the property set valid over a time period. An event occurs at the transition between states. [1]

In 1974 the cost of the book rose, from $14.95 to $16.95. That change in cost is an event.

In 1980 the binding was changed to softcover and the cost dropped to $8.95. That’s a second event.

This graphic depicts the events (and states):

The time varying properties of Book are encapsulated in a container called Time Slice.  The following graphic shows the Book’s two time-varying properties (Binding and Cost) embedded inside a Time Slice container:

ValidTime = the time period for which the Time Slice is valid.

Here is an XML document; the time slices show the history of changes:

Now let’s see how to implement this using XML Schema.

Create a schema file for TimeSlice. Declare a TimeSlice element. Inside TimeSlice declare ValidTime, which is to contain the Start and End elements. After ValidTime is where the time-varying properties are to be placed, so that is an extension point:

In a separate schema file, declare the Book element. The Book element contains Title and Author (non-time-varying properties). After that comes the time-varying properties, so reference the TimeSlice element in the other schema file. Lastly, separate from the Book element declaration, declare the time-varying properties: Binding and Cost.

Here’s the arrangement of files:

Now let’s see the actual schema files. Here is the temporal schema file:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   
    
<xs:element name="TimeSlice">
       
<xs:complexType>
           
<xs:sequence>
               
<xs:element name="ValidTime">
                   
<xs:complexType>
                       
<xs:sequence>
                           
<xs:element name="Start">
                                
<xs:simpleType>
                                   
<xs:union memberTypes="xs:dateTime xs:gYear" />
                               
</xs:simpleType>
                           
</xs:element>
                           
<xs:element name="End" minOccurs="0">
                               
<xs:simpleType>
                                   
<xs:union memberTypes="xs:dateTime xs:gYear" />
                               
</xs:simpleType>
                           
</xs:element>
                        
</xs:sequence>
                   
</xs:complexType>
               
</xs:element>
               
<!-- time-varying properties go here -->
               
<xs:any maxOccurs="unbounded" />
           
</xs:sequence>
       
</xs:complexType>
   
</xs:element>

</xs:schema>

Here is the Book schema file:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   
    
<xs:include schemaLocation="TimeSlice.xsd" />
   
    
<xs:element name="Book">
       
<xs:complexType>
           
<xs:sequence>
                
<xs:element name="Title" type="xs:string" />
               
<xs:element name="Author" type="xs:string" />
               
<xs:element ref="TimeSlice" maxOccurs="unbounded" />
           
</xs:sequence>
           
<xs:attribute name="id" type="xs:ID" />
       
</xs:complexType>
   
</xs:element>
   
    
<!-- Time-varying properties -->
   
<xs:element name="Binding">
       
<xs:simpleType>
           
<xs:restriction base="xs:string">
               
<xs:enumeration value="hardcover" />
               
<xs:enumeration value="softcover" />
           
</xs:restriction>
       
</xs:simpleType>
   
</xs:element>
   
<xs:element name="Cost">
       
<xs:simpleType>
           
<xs:restriction base="xs:string">
               
<xs:pattern value="$[0-9]+\.[0-9][0-9]" />
           
</xs:restriction>
       
</xs:simpleType>
   
</xs:element>
</xs:schema>

Here is a sample XML instance document:

<Book id="RB">
   
<Title>Illusions</Title>
   
<Author>Richard Bach</Author>
   
<TimeSlice>
        
<ValidTime>
           
<Start>1970</Start>
           
<End>1974</End>
       
</ValidTime>
       
<Binding>hardcover</Binding>
       
<Cost>$14.95</Cost>
   
</TimeSlice>
   
<TimeSlice>
       
<ValidTime>
           
<Start>1974</Start>
            
<End>1980</End>
       
</ValidTime>
       
<Binding>hardcover</Binding>
       
<Cost>$16.95</Cost>
   
</TimeSlice>
   
<TimeSlice>
       
<ValidTime>
           
<Start>1980</Start>
       
</ValidTime>
       
<Binding>softcover</Binding>
       
<Cost>$8.95</Cost>
   
</TimeSlice>
</Book>

Acknowledgement: the above is a synopsis and simplification of the AIXM (Aeronautical Information Exchange Model) Temporality Model (http://aixm.aero/sites/aixm.aero/files/imce/AIXM51/aixm_temporality_1.0.pdf). The example shown is my own.

/Roger

[1] Quote from the AIXM Temporality Model paper.



[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