I have a kml file that is generated by FME that I use as a layer in Google Maps. The auto generated kml file has a lot of kml features/elements that are not required for the display, making the kml file unnecessary bulky.
Is there a way to remove such features? I have done this by hand and can confirm that the kml file still displays correctly in Google Maps.
I assume that the XML Updater should be used for this, but I have not been able to get the required results. I most probably did something wrong in my implementation with my limited understanding of how it is supposed to be used. Perhaps there is a way to do this with the kml transformers, which I was not able to find. Any inputs on how to resolve this would be much appreciated.
As an example, say you have the following (sample) kml file where you would like to remove elements/features.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by FME 2018.0.0.0 (Build 18284) -->
<kml xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>lines</name>
<visibility>1</visibility>
<Schema name="abc" id="kml_schema_ft_abc">
<SimpleField type="xsd:string" name="Field1">
<displayName>Field1</displayName>
</SimpleField>
<SimpleField type="xsd:string" name="Field2">
<displayName>Field2</displayName>
</SimpleField>
</Schema>
<Schema name="def" id="kml_schema_ft_def">
<SimpleField type="xsd:string" name="Field1">
<displayName>Field1</displayName>
</SimpleField>
<SimpleField type="xsd:string" name="Field2">
<displayName>Field2</displayName>
</Schema>
<Folder id="kml_ft_def">
<name>def</name>
<Placemark id="kml_1">
<name>kml_1</name>
<snippet> </snippet>
<description><!;CDATAT<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
<th>Field1</th>
<td>Field1 result here</td>
</tr><tr bgcolor="">
<th>Field2</th>
<td>Field2 result here</td>
</tr><tr bgcolor="#E3E3F3">
</tr></table></center>]]></description>
<ExtendedData>
<SchemaData schemaUrl="#kml_schema_ft_def">
<SimpleData name="Field1">Field1 result here</SimpleData>
<SimpleData name="Field2">Field2 result here</SimpleData>
</SchemaData>
</ExtendedData>
<LineString>
<coordinates> <!-- set of coordinates here --></coordinates>
</LineString>
</Placemark>
<Placemark id="kml_2">
<name>kml_2</name>
<snippet> </snippet>
<description><!;CDATAT<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
<th>Field1</th>
<td>Field1 result here</td>
</tr><tr bgcolor="">
<th>Field2</th>
<td>Field2 result here</td>
</tr><tr bgcolor="#E3E3F3">
</tr></table></center>]]></description>
<ExtendedData>
<SchemaData schemaUrl="#kml_schema_ft_def">
<SimpleData name="Field1">Field1 result here</SimpleData>
<SimpleData name="Field2">Field2 result here</SimpleData>
</SchemaData>
</ExtendedData>
<LineString>
<coordinates> <!-- set of coordinates here --></coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>
In this case, I would like to remove the Schema and ExtendedData features/attributes from this file. The output should thus look as follows.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by FME 2018.0.0.0 (Build 18284) -->
<kml xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>lines</name>
<visibility>1</visibility>
<Folder id="kml_ft_def">
<name>def</name>
<Placemark id="kml_1">
<name>kml_1</name>
<snippet> </snippet>
<description><!tCDATAA<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
<th>Field1</th>
<td>Field1 result here</td>
</tr><tr bgcolor="">
<th>Field2</th>
<td>Field2 result here</td>
</tr><tr bgcolor="#E3E3F3">
</tr></table></center>]]></description>
<LineString>
<coordinates> <!-- set of coordinates here --></coordinates>
</LineString>
</Placemark>
<Placemark id="kml_2">
<name>kml_2</name>
<snippet> </snippet>
<description><!tCDATAA<center><table><tr><th colspan='2' align='center'><em>Attributes</em></th></tr><tr bgcolor="#E3E3F3">
<th>Field1</th>
<td>Field1 result here</td>
</tr><tr bgcolor="">
<th>Field2</th>
<td>Field2 result here</td>
</tr><tr bgcolor="#E3E3F3">
</tr></table></center>]]></description>
<LineString>
<coordinates> <!-- set of coordinates here --></coordinates>
</LineString>
</Placemark>
</Folder>
</Document>
</kml>
According to what I understand, the XMLUpdater should link to the Document feature of the KML file and write out another KML Document file.
The XMLUpdater has been setup as follows to remove the Schema feature/attribute.
I have also tried setting the XML Path to /*:Shema, but this did not work either. The resulting KML file's structure is completely changed to something like this.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://www.opengis.net/kml/2.2">
<Document id="kml_id_small_sample_data-original_1.1">
<name>kml_id_small_sample_data-original_1.1</name>
</Document></kml>
Any reason what I am doing wrong? I am probably overcomplicating the problem and should have been able to remove unnecessary kml elements/features inside the workflow where the KML file was generated, but I don't know how. :)
Any help is much appreciated.