Pregunta

I recently came across a KML file that had a <Document> inside a <Document> (Actually a Document inside a Folder inside the root Document). Since a Document is a Feature this seems to be valid, but is this semantically acceptable? I am parsing KML in my app, should I accept it or reject it?

¿Fue útil?

Solución

Both the Document and Folder elements in KML are container types and it is perfectly valid to have a Document inside a Document, Document inside a Folder, Folder inside a Document, etc. In nearly all cases the Folder and Document can be used interchangeably.

Conceptually it makes sense for "Folders" to have "Documents" inside them but there is no such restriction with KML Folders or Documents. The only semantic difference between a Document and a Folder within the KML 2.2 Specification is that only the Document can have a Schema element or Shared Styles as child elements and the Folder cannot. Other than this the Folder and Document are the same.

Here's the syntax summary description of "Folder" and "Document" elements from KML Reference:

<Folder id="ID">
  <!-- inherited from Feature element -->
  <name>...</name>                      <!-- string -->
  ...
  <ExtendedData>...</ExtendedData>
  <!-- specific to Folder -->
  <!-- 0 or more Feature elements -->
</Folder>

<Document id="ID">
  <!-- inherited from Feature element -->
  <name>...</name>                      <!-- string -->
  ...
  <ExtendedData>...</ExtendedData>
  <!-- specific to Document -->
  <!-- 0 or more Schema elements -->
  <!-- 0 or more Feature elements -->
</Document>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top