Example xs:duration

The duration "P2M26DT14H18M" is split into two separate values "P2M" and "P26DT14H18M". Notice the missing year and seconds components, any component is optional. Whereas the value space of duration is partially ordered, the spaces of these year/month and day/time types are totally ordered.

<?xml version="1.0" encoding="UTF-8"?>
<duration xmlns="http://example.org/">P2M26DT14H18M</duration>

The xml schema for this is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/">
        <xs:element name="duration" type="xs:duration" />
</xs:schema>

The object of the 'duration' statement is now a bnode with a pair of rdf:values, representing the two components of the original duration. These values may be distinguished by their type. The base is http://example.org/base.

# Base: http://example.org/elementDuration.xml
@prefix ns1:     <http://example.org/def/> .
@prefix xs:      <http://www.w3.org/2001/XMLSchema> .
@prefix ns2:     <http://example.org/> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xs_:     <http://www.w3.org/2001/XMLSchema#> .
@prefix :        <#> .

<>    ns2:duration
              [ rdf:value "P26DT14H18M"^^xs_:dayTimeDuration , "P2M"^^xs_:yearMonthDuration
              ] .

Mapping back to XML, we make use of the fact that these year/month and day/time types are sub-classes of duration. Durations are added component-wise, so we needn't be concerned with (indeterminate) carry from days to months.


Generated on Mon Jun 18 16:02:38 2007 for Gloze by  doxygen 1.5.0