span8
斯潘4
示例工作空间.zip
Question: How do I expose feature attributes from a KML
I can see the attributes within a description balloon within Google Earth.However,如果我试图用KML阅读器或数据检查器读取文件,我无法查看用户属性。
What do I need to do to load the attributes to another file type such as the shapefiles (shp)?
Answer: We need to use XQueryExtractor to get table attributes from the KML file.
1.Let's look at the source data on Google Earth.它显示一个具有属性的表。
在Google Earth中查看的源代码kml
在文本编辑器中打开kml文件,您可以看到这个属性表嵌入在标记中,并且是用HTML编写的。
2。在您的FME工作区中,add HTMLToXHTMLConverter to convert HTML to XHTML.这样可以确保标记包含有效的XHTML,并且元素正确嵌套。
HTMLToXHTMLConverter parameters
3.Add XQueryExtractor.Enter the following XQuery Expression to parse attribute names and values inside the
declare default element namespace "http://www.w3.org/1999/xhtml";for $x in /html/body/table/tr/td/table/trreturn fme:set-attribute($x/td[1]/text(),$x/td[2]/text())
如果您要在XQuery上查找教程,请访问W3Schools.
XQueryExtractor参数
4。Connect to the Data Inspector.
工作流管亚搏在线理系统工作流
5。在数据检查器中查看功能。
Result: attributes names and attribute values are exposed in the Inspector.
6.Expose attributes.如果您希望稍后在工作流中使用这些属性或将它们写入目标数据集,亚搏在线you will likely need to expose them.This can be accomplished by either using the AttributeExposer transformer after the XMLXQueryExtractor,or the Expose Attributes parameter within the XMLXQueryExtractor.
谢谢,这是个很好的例子!However not every *kml is so nicely structured like this.In my example the table in
something like this:
传感器阿洛斯
Mode: FBS8
ProcessorJAXA
假设需要更改XQuery表达式,但是如何呢?
如果我的描述不清楚,请找到随附的KML。对于从这个kml中提取属性的一些提示和示例,我们将不胜感激。Kind regards,克里斯。
而不是需要特定XQuery表达式的XQueryExtractor,normally for html tables you could try the XMLFlattener with feature path = 'tr' which will flatten out your description's table rows into its component fields in the form of row.column.However,我看了一下您的KML,发现数据不是存储在HTML表中,而是存储在一个大的文本字段中。因此,必须使用文本处理来提取所需的值。我会跟进你的支持案例,进一步解释这一点。
这是一个很好的例子,但出于某种原因,它对我来说不起作用,即使我的数据结构非常相似。I found that this did work..
declare default element namespace "http://www.w3.org/1999/xhtml";for $x in //tr where (exists($x/td[1]) and compare($x/td[2]/text(),""))return fme:set-attribute($x/td[1]/text(),$x/td[2]/text())
/tr提取行,regardless of what comes before,which is very handy so that you don't really need to figure out the structure.
The where(exists()) part is necessary for unknown reasons.Anything I tried without a where clause returned no results.compare子句删除了空参数,which were formatted as <> in my data.我不确定这是KML标准还是我的数据集特有的。
我还发现我必须暴露我想要保留的属性,并将它们添加到目的地。这样就省去了对结果字段的理解。
Hope this helps someone...
declare default element namespace "http://www.w3.org/1999/xhtml";for $x in /html/body/table/trreturn fme:set-attribute($x/td[1]/text(),$x/td[2]/text())
谢谢你的例子。
我还有一个与本例格式不同的kml。我尝试过XQueryExtractor和XML扁平化器,但未能提取出属性。我想知道是否有人可以帮助我获得正确的查询,从以下XML格式中提取名称和属性:
“http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
http://www.w3.org/1999/xhtml“>
V18279201018990_000.jpg
Latitude:37.424416°
Longitude:- 82.930091°
Roll:- 15.832788°
音高:1.726352°
Heading:161.467052;
高度:230.000
GPS周秒591967.285977;0.000
?2019安全亚搏在线软件公司|合法的