PHP 中的 GPX 到 KML
我正在从事一个项目,人们上传 GPX,我试图将 GPX 文件转换为 KML 文件,因此他们可以选择以两种格式下载。
我发现一个 XSLT 文件据说可以将 GPX 转换为 KML,但是当我尝试使用 XSLTProcessor 在 php 中进行转换时,它给了我一些错误,指出某些函数未找到。我检查了 XSLT 文件,这些函数都在那里。我对 XSLT 不太熟悉,所以如果有人能给我一些指导,那就太好了。
xslt 文件位于此处: http://members.home.nl/cybarber/geomatters/ FlitspaalGPX2KML.xslt
gpx 文件位于此处:http://geobetty .com/maps/download/8/archuletas-acres.gpx
这是代码:
<?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); ?>
这些是我的错误:
xmlXPathCompOpEval:找不到函数 distCosineLaw 未注册的函数 xmlXPathCompiledEval:堆栈上剩余 3 个
对象
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
XSLT 转换是专门为由 MSXML 运行而编写的,并使用仅由 MSXML XSLT 处理器实现的扩展元素
。解决方案:要么:
使用 MSXML 运行转换(版本 3、4 或 6)。
实现扩展函数,以便与您的 XSLT 处理器一起使用(如果可能)。
查找 XSLT 3.0 XSLT 处理器的早期实现。 XSLT 3.0 使用 XPath 3.0 并且在 XPath 3.0 中主要三角函数和指数函数已成为标准函数。
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.
您还可以尝试使用 gpsbabel (外部程序)进行转换。这样您也将获得对许多其他格式的自动支持。缺点是您需要安装外部程序,这可能会也可能不会,具体取决于您的主机。
You could also try to use gpsbabel (an external program) to do the conversion. This way you will gain automatic support for lots of other formats as well. The downside is that you need to install an external program which may or may not be possible depending on your hosting.
我编写了这段代码来将 GPX 转换为 KMl,但如何设置样式和更多 dom。
I have written this code to convert GPX to KMl but how to set style and more dom.