I have prepared an initial draft for an XML DTD for returning layer selection information. The DTD, and example returned XML for GeoTIFF and VRF is attached.
I will include the entire GeoTIFF XML for a datastore with access to two GeoTIFF files named "irvine" and "eltoro" for a simple introduction, and then I will use the VRF example to show a more complicated case.
<?xml version="1.0" ?> <!DOCTYPE OGDILayerInfo SYSTEM "ogdilayerinfo30.dtd"> <OGDILayerInfo> <layersyntax> <layertoken type="item">layername</layertoken> </layersyntax> <layergroup> <layer> <itemname item="layername">irvine</itemname> <defaultname>irvine</defaultname> <family>Matrix</family> <family>Image</family> </layer> <layer> <itemname item="layername">eltoro</itemname> <defaultname>eltoro</defaultname> <family>Matrix</family> <family>Image</family> </layer> </layergroup> </OGDILayerInfo>The returned information is broken down into two basic sections, the <layersyntax> section and the <layergroup> section.
VRF Format gives us a sophisticated example:
<layersyntax> <layertoken type="item">class</layertoken> <layertoken type="separator">@</layertoken> <layertoken type="item">coverage</layertoken> <layertoken type="separator">(</layertoken> <layertoken type="expression" format="sql_where" default="*" desc="Attribute Expression or *">expression</layertoken> <layertoken type="separator">)</layertoken> </layersyntax>The <layersyntax> section contains one or more <layertoken> items. Each layer token has a type attribute which must be one of:
item: The contained text (such as class or coverage) is a variable value which is translated to an actual piece of text based on the <itemname> tokens within the <layergroup>s below. All possible values for items will be implicit in the following <layergroup>s. separator: The contained text is literally included in the resulting layer name. While the examples here all show single characters, that isn't necessarily the case. expression: This is a variable piece of text which must be supplied by the user but which isn't fully defined within the XML metadata. The most common example of an expression is the attribute query that can be passed to the VRF and similar drivers. A number of additional attributes can be meaningfully attached to an expression token, but they are all optional. format: A name defining the exact format of the expression from a list of well known formats. One might be "sql_where" indicating that an SQL WHERE statement attribute syntax is legal. While the III should define some well known formats, it would also be legal for vendors to add their own which might only be meaningful to their own clients. default: A reasonable default value that can be used for this expression. In the VRF case a value of "*" for the expression means all features. desc: A text string that could be displayed to the user as a clue to enter values for this expression.
<layergroup> <itemname item="coverage">col</itemname> <desc>Cultural Landmarks</desc> <layer> <itemname item="class">buildnga</itemname> <defaultname>buildnga@col(*)</defaultname> <family>Area</family> </layer> <layer> <itemname item="class">landmrka</itemname> <defaultname>landmrka@col(*)</defaultname> <family>Point</family> </layer> </layergroup>
The <layer> elements can also have the <defaultname> and <family> elements.
<?xml version="1.0" ?> <!DOCTYPE OGDILayerInfo SYSTEM "ogdilayerinfo30.dtd"> <OGDILayerInfo> <layersyntax> ... </layersyntax> <layergroup> ... </layergroup> </OGDILayerInfo>Note that DTD (ogdilayerinfo.dtd) isn't downloadable from the driver, but will be available from within the III OGDI specification. In the future, when the DTD is extended the version number embedded within the DTD can be changed.
Clients should generally be written to ignore the DTD document name returned, and to proceed on their best knowledge of the format. They should be permissive (ignore) elements and element attributes they don't understand to be as compatible as possible with future versions of the XML DTD.
Do we wish to encode such a restriction into this data model?
However, I am slightly nervous about this due to the different meaning given to cln_GetDictionary() from that in the old API (even though I know the old function was deprecated).
Furthermore, the Global Geomatics API doesn't quite model the generality of what the XML encoding can define, which may be a problem.
Nevertheless, I would like to see a client side API written in upcoming weeks to facilitate adoption of the XML encoding. Furthermore, it would be nice if that API also had fallback rules based on the driver name for drivers that don't implement the new XML metadata (via cln_UpdateDictionary( "LAYERLIST")) properly.
There are a few simple XML parsers available on the net (public domain or equivelent) which could be used for this. A quick look around suggests to me that the traditional expat XML parser from James Clark would be suitable to our purposes, and not significantly bloat OGDI.
I am also happy to prepare additional examples if there are drivers that people don't understand how they would map into this format.
<?xml version="1.0" ?> <!DOCTYPE OGDILayerInfo SYSTEM "ogdilayerinfo.dtd"> <OGDILayerInfo> <layersyntax> <layertoken type="item">layername</layertoken> </layersyntax> <layergroup> <layer> <itemname item="layername">irvine</itemname> <defaultname>irvine</defaultname> <family>Matrix</family> <family>Image</family> </layer> <layer> <itemname item="layername">eltoro</itemname> <defaultname>eltoro</defaultname> <family>Matrix</family> <family>Image</family> </layer> </layergroup> </OGDILayerInfo>
<?xml version="1.0" ?> <!DOCTYPE OGDILayerInfo SYSTEM "ogdilayerinfo.dtd"> <OGDILayerInfo> <layersyntax> <layertoken type="item">class</layertoken> <layertoken type="separator">@</layertoken> <layertoken type="item">coverage</layertoken> <layertoken type="separator">(</layertoken> <layertoken type="expression" format="sql_where" default="*" desc="Attribute Expression or *">expression</layertoken> <layertoken type="separator">)</layertoken> </layersyntax> <layergroup> <itemname item="coverage">col</itemname> <desc>Cultural Landmarks</desc> <layer> <itemname item="class">buildnga</itemname> <defaultname>buildnga@col(*)</defaultname> <family>Area</family> </layer> <layer> <itemname item="class">landmrka</itemname> <defaultname>landmrka@col(*)</defaultname> <family>Point</family> </layer> </layergroup> </OGDILayerInfo>