You are here: Popular Formats > Google KML Reader/Writer > Feature Representation > User Defined Schema

User Defined Schema

In addition to the fixed schema, and explicit definition of extended data, the KML reader and writer also provide automatic support for user-defined schema.

Reader

The KML reader supports reading KML datasets that use KML 2.0, 2.1, or 2.2 schema declarations.

Upon opening a KML dataset, the KML reader will attempt to scan the dataset's schema by reading all the Schema elements in the file, and traversing all schemaUrl and NetworkLink references in the file. The default schema scanning behavior can be disabled with the SCAN_SCHEMA reader directive.

If Schema declarations are found, the associated Placemark elements will be read as user-defined feature types with the associated set of user-defined attributes. In addition to the user-defined attributes, the kml_data and kml_schema_data structured list attributes will be created as necessary.

Writer

The KML writer only supports writing KML 2.2 schema elements. Older style schema formats have been deprecated, and are not well supported by applications other than Google Earth.

The KML writer creates the appropriate <Schema> elements for each user-defined featuretype; each feature is written as either a Placemark or GroundOverlay depending on the feature's geometry type. This behavior can be disabled using the OUTPUT_SCHEMA writer directive.

When writing large, multi-file datasets, it is useful to be able to store the schema data in an external file. The KML writer allows the filename of an external schema file to be specified using the SCHEMA_DOC directive.

Note: The value must be a filename including the "kml" extension, and will be overwritten during the translation. The schemaUrl attributes of each <SchemaData> element will be adjusted to point to the external file.