Untitled 1

Chronomet Stopwatch Log Schema

The following describes the XML schema (XSD) for the stopwatch log when exported by Chronomet:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://bagell.com/ChronoXMLSchema"
        elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:tns="http://bagell.com/ChronoXMLSchema">

    <simpleType name="splitType">
        <restriction base="duration"/>
    </simpleType>

    <complexType name="StopwatchType">
        <sequence>
            <element name="split" type="tns:splitType"/>
        </sequence>
        <attribute name="name" type="string"/>
        <attribute name="timestamp" type="dateTime"/>
        <attribute name="elapsed" type="duration"/>
    </complexType>

    <complexType name="ChronoListType">
        <sequence>
            <element name="stopwatch" type="tns:StopwatchType"/>
        </sequence>
    </complexType>

    <element name="chronolog" type="tns:ChronoListType"/>
</schema>
 

An example log might be:

<?xml version="1.0" encoding="utf-8"?>
<chronolog xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
           xmlns='http://bagell.com/ChronoXMLSchema'>
    <chronograph name="SW2" timestamp="2013-10-22T21:42:58.893-07:00" elapsed="PT0H0M2.64S">
    </chronograph>
    <chronograph name="SW1" timestamp="2013-10-22T21:42:44.17-07:00" elapsed="PT0H0M7.39S">
        <split>PT0H0M2.1S</split>
        <split>PT0H0M4.32S</split>
        <split>PT0H0M6.40S</split>
    </chronograph>
</chronolog>
 

In the previous example, there are two log entries, the second of which has three split times associated with it.

The elapsed time for a stopwatch is stored in the 'elapsed' attribute on the 'chronograph' element. The format for this is the W3C standard duration element. The split times also use the same format.

The timestamp uses the W3C dateTime format.

Parsing the log

Here's how you can parse the log and extract the elapsed times using Windows PowerShell. The following script assumes the stopwatch log is in a file called 'chronometLog.xml'.

c:\> $log = [xml] (gc chronometLog.xml)
c:\> $log.chronolog.chronograph | %{[xml.xmlconvert]::ToTimeSpan($_.elapsed)}

Which produces the output:

Days : 0
Hours : 0
Minutes : 0
Seconds : 2
Milliseconds : 640
Ticks : 26400000
TotalDays : 3.05555555555556E-05
TotalHours : 0.000733333333333333
TotalMinutes : 0.044
TotalSeconds : 2.64
TotalMilliseconds : 2640

Days : 0
Hours : 0
Minutes : 0
Seconds : 7
Milliseconds : 390
Ticks : 73900000
TotalDays : 8.55324074074074E-05
TotalHours : 0.00205277777777778
TotalMinutes : 0.123166666666667
TotalSeconds : 7.39
TotalMilliseconds : 7390