OAFA GML: an once-and-for-all GML application schema

ISO 19136 になり、Encoding Specification から Encoding Standard に格上げ(?)された、Geography Markup Language GML 3.2.1。私は XML Schema とはなるべくつきあいたくないので、「これで何にでも使える」極端に単純な GML Application Schema を試作してみました。
Geography Markup Language (GML) 3.2.1 is there as an Encoding Standard, not an Encoding Specification*1. I prototyped an extremely simple general-purpose GML Application Schema, because I do not like to hang around the world of XML Schema. I name it once-and-for-all (OAFA) GML application schema.

the motto

GML を採用しよう。そして GML なんて忘れよう。
Adopt GML, and forget it.

the design principle

地物は JavaScript のオブジェクトや Ruby のハッシュのようなものだ。
A (geographic) feature is like a JavaScript object or a Ruby hash.

an example of OAFA GML document

ルート要素は oafa で、それは任意の数の Feature 要素を持ちます。それぞれの Feature 要素は任意の数の attribute 要素を持ちます。それぞれの attribute 要素は name と名付けられた属性を持たなければならず、また要素の内容は任意です。
The root element is oafa, which contains arbitary number of Feature element. Each Feature element has arbitary number of attribute element. Each attribute element must have attribute named name, and can have arbitary content.
以下、OAFA GML のサンプル文書(oafa_instance.gml)です。
Below is a sample OAFA GML document named oafa_instance.gml.

<?xml version="1.0" encoding="UTF-8"?>
<oafa xmlns="http://svgmapdata.sakura.ne.jp/oafa" 
      xmlns:gml="http://www.opengis.net/gml">
  <gml:description>This is a sample data.</gml:description>
  <Feature>
    <attribute name="the_geom">
      <gml:Point>
	<gml:pos>35 135</gml:pos>
      </gml:Point>
    </attribute>
    <attribute name="temperature">22</attribute>
  </Feature>
</oafa>

the .xsd for OAFA GML

oafa.xsd です。このファイルは、http://svgmapdata.sakura.ne.jp/oafa/oafa.xsd にもアップロードしておきました。そうしておけば XML Schema 検証器が使いやすいと思いましたので。
Here is oafa.xsd. I also uploaded this .xsd file at http://svgmapdata.sakura.ne.jp/oafa/oafa.xsd so that XML Schema validators can use it.

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://svgmapdata.sakura.ne.jp/oafa"
	xmlns:oafa="http://svgmapdata.sakura.ne.jp/oafa"
	xmlns:gml="http://www.opengis.net/gml"
	xmlns="http://www.w3.org/2001/XMLSchema"
	elementFormDefault="qualified" version="0.0.1">
  <import namespace="http://www.opengis.net/gml" 
	  schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
  <annotation>
    <documentation>
      A simple and open (as in open class) GML schema.
      
      Every Feature in OAFA GML schema works like a hash in Ruby or 
      an object in JavaScript. It is extremely typeless.

      Technical note:
      This schema imports http://schemas.opengis.net/gml/3.1.1/base/gml.xsd,
      not http://schemas.opengis.net/gml/3.2.1/gml.xsd, because the latter
      does not work, at least with Sun Mult-schema XML validator 20070407.
    </documentation>
  </annotation>
  <complexType name="AttributeType" mixed="true">
    <annotation>
      <documentation>
	As a convention, the 'main' geometric/geographic attribute can
	preferably have the name 'the_geom', in accord with GDAL/OGR.
	But this convention is not enforced at the GML/XML schema level.
      </documentation>
    </annotation>
    <sequence>
      <any namespace="##any" minOccurs="0"/>
    </sequence>
    <attribute name="name" type="string" use="required"/>
  </complexType>
  <element name="attribute" type="oafa:AttributeType"/>
  
  <complexType name="FeatureType">
    <complexContent>
      <extension base="gml:AbstractFeatureType">
	<sequence>
	  <element ref="oafa:attribute" minOccurs="0" maxOccurs="unbounded"/>
	</sequence>
      </extension>
    </complexContent>
  </complexType>
  <element name="Feature" type="oafa:FeatureType"/>
  
  <complexType name="OAFAType">
    <complexContent>
      <extension base="gml:AbstractFeatureCollectionType">
	<sequence>
	  <element ref="oafa:Feature" minOccurs="0" maxOccurs="unbounded"/>
	</sequence>
      </extension>
    </complexContent>
  </complexType>
  <element name="oafa" type="oafa:OAFAType"/>
</schema>

validation

Sun Multi-schema XML validator (MSV) を使って、oafa_instance.gml が oafa.xsd に対して妥当であることを検証しました。
Using Sun Multi-schema XML validator (MSV), I checked that oafa_instance.gml is valid against oafa.xsd:

$ java -jar msv.jar -warning oafa.xsd oafa_instance.gml 
スキーマを読み込んでいます...
type属性がないのでこの要素の中身は全く検証されませんが、意図した動作でしょうか?もしそうなら、type="anyType"と明示的にこれを記述することをお奨めします
  30:42@http://schemas.opengis.net/gml/3.1.1/base/gmlBase.xsd
検証しています: oafa_instance.gml
文書は妥当(valid)です

警告は opengis.net にあるスキーマに対して出ているものです。
The warning is for the schema put at schemas.opengis.net.

Conclusion

oafa.xsd に対して妥当な文書を作れば、その文書は GML 文書であると言えます(たぶん)。つまり、その文書は国際規格 19136 に準拠した文書になるのです。この単純なスキーマ (oafa.xsd) によって、地理情報流通における行政的・政治的困難を取り除く助けになればうれしいと思います。
If you make document valid against oafa.xsd, (hopefully) the document is a GML document. This means your document is compliant with International Standard 19136. I hope this simple schema (oafa.xsd) will help you cope with administrative/political difficulties.
この oafa.xsd に問題が見つかれば、このブログでフォローアップしたい(つまり、あとで書く)と思います。
I will put some followups here in this blog if I find some problems with this oafa.xsd.