I'm writing some code to output a KML file, with certain application-specific info stored in the ExtendedData nodes. As an easy way to debug the validity of my KML, I'm using Google Earth with the "Show prompts for all errors" option enabled (http://screencast.com/t/UDkJc6Nv5G4).
我正在编写一些代码来输出KML文件,其中某些特定于应用程序的信息存储在ExtendedData节点中。作为调试KML有效性的简单方法,我使用Google Earth并启用了“显示所有错误的提示”选项(http://screencast.com/t/UDkJc6Nv5G4)。
I'm trying to write the ExtendedData as untyped arbitrary tags, as documented in the KML reference under namespace_prefix:other (see: https://developers.google.com/kml/documentation/kmlreference?csw=1#extendeddata) The problem is, even if I replicate their sample code precisely, Google Earth complains about an unknown element: http://screencast.com/t/bCMgaDiDYdWt.
我正在尝试将ExtendedData编写为无类型的任意标记,如namespace_prefix:other下的KML参考中所述(请参阅:https://developers.google.com/kml/documentation/kmlreference?csw = 1 #extendeddata)问题就是说,即使我准确地复制了他们的示例代码,谷歌地球仍抱怨一个未知元素:http://screencast.com/t/bCMgaDiDYdWt。
Here's the complete KML:
这是完整的KML:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Sample KML.kml</name>
<Placemark>
<name>Test KML</name>
<Point>
<coordinates>-118.405022621,33.943893977,0</coordinates>
</Point>
<ExtendedData xmlns:prefix="camp">
<camp:number>14</camp:number>
<camp:parkingSpaces>2</camp:parkingSpaces>
<camp:tentSites>4</camp:tentSites>
</ExtendedData>
</Placemark>
</Document>
</kml>
I'm aware that there are alternative ways to include application-specific data (i.e. <Data>, <SchemaData>, etc) - but for this question, I'm interested in figuring out why Google's own software reports this as invalid, when it comes straight from their own example. Have I left something else out of the KML, or am I misinterpreting the docs?
我知道有其他方法可以包含特定于应用程序的数据(即
,
2 个解决方案
#1
4
The example is correct. However, when "Show prompts for all errors" option is enabled in Google Earth, arbitrary namespaces for extended data is always displayed as an error.
这个例子是对的。但是,当在Google地球中启用“显示所有错误的提示”选项时,扩展数据的任意名称空间始终显示为错误。
This was reported as an issue in 2009 but has not been fixed. https://code.google.com/p/earth-issues/issues/detail?id=438
这在2009年报告为一个问题,但尚未确定。 https://code.google.com/p/earth-issues/issues/detail?id=438
Using arbitrary namespaces for extended data is a valid usage of KML as defined by the KML 2.2 specification so it's not really an error. Google Earth is just reporting that it doesn't know what to do with that element which is correct in the sense that when adding arbitrary XML data to a Feature Google Earth preserves this data but does not process it. It should not be reported as an error.
对扩展数据使用任意名称空间是KML 2.2规范定义的KML的有效用法,因此它实际上不是错误。谷歌地球只是报告它不知道如何处理该元素是正确的,因为在向一个功能添加任意XML数据时,Google地球会保留这些数据但不处理它。不应将其报告为错误。
Here is an example using a real namespace for extended data in KML. This example uses Dublin Core namespace for metadata to KML: https://productforums.google.com/d/msg/maps/8pbTmPIbj18/J_w2mjRWyQoJ
下面是一个使用真实命名空间来表示KML中扩展数据的示例。此示例使用Dublin Core命名空间将元数据用于KML:https://productforums.google.com/d/msg/maps/8pbTmPIbj18/J_w2mjRWyQoJ
If want to validate arbitrary namespaces in your KML you can't use Google Earth's validation. You need a XML Schema-aware validator such as the standalone comment-line tool XmlValidate. Further discussion of validation in Google Earth can be found here.
如果要在KML中验证任意名称空间,则无法使用Google地球的验证。您需要一个支持XML Schema的验证器,例如独立的注释行工具XmlValidate。有关Google地球验证的进一步讨论,请点击此处。
#2
1
I just got bit by this too -- upvotes for the question and answer. But I did want to add that your XML that you copied isn't technically correct. You got yours from:
我也对此感到满意 - 对问答的支持。但我确实想补充一点,你复制的XML在技术上并不正确。你有自己的:
https://developers.google.com/kml/documentation/kmlreference#extendeddata
whereas the better explanation and correct xml is located at:
而更好的解释和正确的xml位于:
https://developers.google.com/kml/documentation/extendeddata
As mentioned -- it does not help with those errors. If your version works at all it is because you are using the namespace directly, and not the prefix.
如上所述 - 它对这些错误没有帮助。如果您的版本完全正常,那是因为您直接使用命名空间,而不是前缀。
Here is the example from the second site:
以下是第二个站点的示例:
<ExtendedData xmlns:camp="http://campsites.com">
<camp:number>14</camp:number>
<camp:parkingSpaces>2</camp:parkingSpaces>
<camp:tentSites>4</camp:tentSites>
</ExtendedData>
Note that "prefix" is replace with the actual prefix ("camp"), and the namespace is used to define the prefix, but isn't used.
请注意,“prefix”替换为实际前缀(“camp”),命名空间用于定义前缀,但不使用。
Just 2c.
#1
4
The example is correct. However, when "Show prompts for all errors" option is enabled in Google Earth, arbitrary namespaces for extended data is always displayed as an error.
这个例子是对的。但是,当在Google地球中启用“显示所有错误的提示”选项时,扩展数据的任意名称空间始终显示为错误。
This was reported as an issue in 2009 but has not been fixed. https://code.google.com/p/earth-issues/issues/detail?id=438
这在2009年报告为一个问题,但尚未确定。 https://code.google.com/p/earth-issues/issues/detail?id=438
Using arbitrary namespaces for extended data is a valid usage of KML as defined by the KML 2.2 specification so it's not really an error. Google Earth is just reporting that it doesn't know what to do with that element which is correct in the sense that when adding arbitrary XML data to a Feature Google Earth preserves this data but does not process it. It should not be reported as an error.
对扩展数据使用任意名称空间是KML 2.2规范定义的KML的有效用法,因此它实际上不是错误。谷歌地球只是报告它不知道如何处理该元素是正确的,因为在向一个功能添加任意XML数据时,Google地球会保留这些数据但不处理它。不应将其报告为错误。
Here is an example using a real namespace for extended data in KML. This example uses Dublin Core namespace for metadata to KML: https://productforums.google.com/d/msg/maps/8pbTmPIbj18/J_w2mjRWyQoJ
下面是一个使用真实命名空间来表示KML中扩展数据的示例。此示例使用Dublin Core命名空间将元数据用于KML:https://productforums.google.com/d/msg/maps/8pbTmPIbj18/J_w2mjRWyQoJ
If want to validate arbitrary namespaces in your KML you can't use Google Earth's validation. You need a XML Schema-aware validator such as the standalone comment-line tool XmlValidate. Further discussion of validation in Google Earth can be found here.
如果要在KML中验证任意名称空间,则无法使用Google地球的验证。您需要一个支持XML Schema的验证器,例如独立的注释行工具XmlValidate。有关Google地球验证的进一步讨论,请点击此处。
#2
1
I just got bit by this too -- upvotes for the question and answer. But I did want to add that your XML that you copied isn't technically correct. You got yours from:
我也对此感到满意 - 对问答的支持。但我确实想补充一点,你复制的XML在技术上并不正确。你有自己的:
https://developers.google.com/kml/documentation/kmlreference#extendeddata
whereas the better explanation and correct xml is located at:
而更好的解释和正确的xml位于:
https://developers.google.com/kml/documentation/extendeddata
As mentioned -- it does not help with those errors. If your version works at all it is because you are using the namespace directly, and not the prefix.
如上所述 - 它对这些错误没有帮助。如果您的版本完全正常,那是因为您直接使用命名空间,而不是前缀。
Here is the example from the second site:
以下是第二个站点的示例:
<ExtendedData xmlns:camp="http://campsites.com">
<camp:number>14</camp:number>
<camp:parkingSpaces>2</camp:parkingSpaces>
<camp:tentSites>4</camp:tentSites>
</ExtendedData>
Note that "prefix" is replace with the actual prefix ("camp"), and the namespace is used to define the prefix, but isn't used.
请注意,“prefix”替换为实际前缀(“camp”),命名空间用于定义前缀,但不使用。
Just 2c.