<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:date="http://exslt.org/dates-and-times" xmlns:oc="http://www.crisisgrid.org/sensorgrid"
    xmlns:gml="http://www.opengis.net/gml" xmlns:om="http://www.opengis.net/om">
    <!--
      Paul Jamason, SOPAC, 09/2006. used to convert a positionCollection xml instance to an html
      table. -->
    <xsl:output method="html"/>
    <xsl:template match="oc:ObservationCollection">
        <table>
            <xsl:for-each select="om:observationMember/oc:PositionMessage">
                <!-- here remove site code if for single site.  need 2 different xsls
                <xsl:sort select="om:relatedFeature/oc:Site/gml:name"/>
                -->
                <xsl:sort select="gml:timeStamp/gml:TimeInstant/gml:timePosition"/>
                <tr>
                    <td>
                        <xsl:value-of select="om:relatedFeature/oc:Site/gml:name"/>
                    </td>
                    <td>
                    <xsl:value-of select="gml:timeStamp/gml:TimeInstant/gml:timePosition"/>
                    </td>
                    <xsl:for-each
                        select="gml:resultOf/gml:CompositeValue/gml:valueComponents/oc:XYZPosition/gml:valueComponents">
                        <td>
                            <xsl:value-of select="oc:X"/>
                        </td>
                        <td>
                            <xsl:value-of select="oc:Y"/>
                        </td>
                        <td>
                            <xsl:value-of select="oc:Z"/>
                        </td>
                    </xsl:for-each>
                    <xsl:for-each
                        select="gml:resultOf/gml:CompositeValue/gml:valueComponents/oc:XYZSigma/gml:valueComponents">
                        <td>
                            <xsl:value-of select="format-number(oc:XSig,'#0.0000')"/>
                        </td>
                        <td>
                            <xsl:value-of select="format-number(oc:YSig,'#0.0000')"/>
                        </td>
                        <td>
                            <xsl:value-of select="format-number(oc:ZSig,'#0.0000')"/>
                        </td>
                    </xsl:for-each>
                    <xsl:for-each
                        select="gml:resultOf/gml:CompositeValue/gml:valueComponents/oc:NEUVelocity/gml:valueComponents">
                        <td>
                            <xsl:value-of select="oc:North"/>
                        </td>
                        <td>
                            <xsl:value-of select="oc:East"/>
                        </td>
                        <td>
                            <xsl:value-of select="oc:Up"/>
                        </td>
                    </xsl:for-each>
                    <xsl:for-each
                        select="gml:resultOf/gml:CompositeValue/gml:valueComponents/oc:NEUVelocitySigma/gml:valueComponents">
                        <td>
                            <xsl:value-of select="format-number(oc:NorthVelSig,'#0.0000')"/>
                        </td>
                        <td>
                            <xsl:value-of select="format-number(oc:EastVelSig,'#0.0000')"/>
                        </td>
                        <td>
                            <xsl:value-of select="format-number(oc:UpVelSig,'#0.0000')"/>
                        </td>
                    </xsl:for-each>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>
</xsl:stylesheet>
