<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:cs="http://www.xfront.com/owl/ontologies/CoordinateSystem/#"
                xmlns:len="http://www.xfront.com/owl/ontologies/Length/#"
                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                version="2.0">
 
    <xsl:output method="html"/>

    <xsl:include href="CoordinateSystem-Include-File.xsl"/>

    <xsl:template match="/">
        <HTML>
            <BODY>
                <xsl:for-each select="/Points/point">
                    <xsl:apply-templates/>
                </xsl:for-each>
            </BODY>
        </HTML>
    </xsl:template>

    <xsl:template match="*[local-name(.) != 'Cartesian-Coordinate-System']">
        <xsl:text>The input data is not in the canonical coordinate system. Converting ...</xsl:text><br/>
        <xsl:variable name="canonical-CoordinateSystem" select="cs:CoordinateSystem(.)"/>
        <xsl:apply-templates select="$canonical-CoordinateSystem"/>
    </xsl:template>

    <xsl:template match="cs:Cartesian-Coordinate-System[(cs:x/len:Length/len:units/@rdf:resource != 'http://www.xfront.com/owl/ontologies/Length/#Metre') or
                                                        (cs:y/len:Length/len:units/@rdf:resource != 'http://www.xfront.com/owl/ontologies/Length/#Metre')]">
        <xsl:text>The input data is in the canonical coordinate system, but the Length of x and/or y is not in canonical form. Converting ...</xsl:text><br/>
        <xsl:variable name="canonicalForm" select="cs:CoordinateSystem(.)"/>
        <xsl:apply-templates select="$canonicalForm"/>
    </xsl:template>

    <xsl:template match="cs:Cartesian-Coordinate-System[(cs:x/len:Length/len:units/@rdf:resource = 'http://www.xfront.com/owl/ontologies/Length/#Metre') and
                                                        (cs:y/len:Length/len:units/@rdf:resource = 'http://www.xfront.com/owl/ontologies/Length/#Metre')]">
        <xsl:text>The input data is in the canonical coordinate system, and it is in canonical form.</xsl:text><p/>

    </xsl:template>

</xsl:stylesheet>