I am working in a project where people upload GPX and I am trying to convert a GPX file into a KML file, so they have the option of downloading in both formats.
I found a XSLT file that supposedly transforms GPX into KML but when I try to do the conversion in php using XSLTProcessor, it gives me some errors saying that some functions are not found. I checked the XSLT file and those functions are there. I am not very familiar with XSLT so if anyone can give me some direction that would be great.
The xslt file is located here: http://members.home.nl/cybarber/geomatters/FlitspaalGPX2KML.xslt
The gpx file is located here: http://geobetty.com/maps/download/8/archuletas-acres.gpx
Here is the code:
<?php
$gpx = new DOMDocument();
$gpx->loadXML($ride);
$xslsheet = new DOMDocument();
$xslsheet->load(DOCROOT . '/lib/gpx-to-kml.xslt');
$xsl = new XSLTProcessor();
$xsl->importStyleSheet($xslsheet);
$kml = $xsl->transformToXML($gpx); ?>
These are my errors:
xmlXPathCompOpEval: function distCosineLaw not found Unregistered function xmlXPathCompiledEval: 3 objects left on the stack
Among others
The XSLT transformation is written especially to be run by MSXML and uses the extension element
<msxsl:script>
which is implemented only by the MSXML XSLT processor.Solution: Either:
Run the transformation with MSXML (ver. 3, 4, or 6).
Implement the extension functions for use with your XSLT processor, if that is possible.
Find an early implementation of an XSLT 3.0 XSLT processor. XSLT 3.0 uses XPath 3.0 and in XPath 3.0 the main trigonometric and exponential functions have been made standard functions of the language.