<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns:f="http://example.org/xslt/functions"
                xmlns:gcd="http://nwalsh.com/xslt/com.nwalsh.xslt.GreatCircle.Distance"
                exclude-result-prefixes="xs f gcd" version="2.0">

<xsl:output method="text"/>

<xsl:variable name="LAX" select="(33.94, -118,40)"/>
<xsl:variable name="BNA" select="(36.12, -86.67)"/>

<xsl:template match="/">
  <xsl:text>Distance: </xsl:text>
  <xsl:value-of select="f:gcd($LAX[1], $LAX[2], $BNA[1], $BNA[2])"/>
  <xsl:text>km
</xsl:text>
</xsl:template>

<xsl:function name="f:gcd" use-when="function-available('gcd:distance')">
  <xsl:param name="lat1"/>
  <xsl:param name="lon1"/>
  <xsl:param name="lat2"/>
  <xsl:param name="lon2"/>
  <xsl:value-of select="gcd:distance($lat1,$lon1,$lat2,$lon2)"/>
</xsl:function>

<xsl:function name="f:gcd" use-when="not(function-available('gcd:distance'))">
  <xsl:param name="lat1"/>
  <xsl:param name="lon1"/>
  <xsl:param name="lat2"/>
  <xsl:param name="lon2"/>
  <xsl:message>Warning: cannot calculate great circle distance!</xsl:message>
  <xsl:value-of select="1000"/>
</xsl:function>

</xsl:stylesheet>