私が解決しようとしている問題は、OpenLayersとTinyOWSの間の相互作用、つまり新しい機能の挿入に関連していますが、JavascriptコードまたはTinyOWS構成は、xml検証の問題とは関係がないため、ここには投稿しません。私は可能な限り問題を切り分けようとしました。スキーマに対するXML検証にlxmlライブラリを使用するpython2コードは次のとおりです。
from lxml import etree
from StringIO import StringIO
parser = etree.XMLParser(no_network=False)
etree.set_default_parser(parser)
schema_doc = etree.parse(StringIO('''\
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" xmlns:tows="http://www.tinyows.org/" targetNamespace="http://www.tinyows.org/" elementFormDefault="qualified" version="1.1">
<xs:import namespace="http://www.opengis.net/wfs" schemaLocation="http://schemas.opengis.net/wfs/1.1.0/wfs.xsd"/>
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
<xs:element name="cities" type="tows:citiesType" substitutionGroup="gml:_Feature"/>
<xs:complexType name="citiesType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="type_id" type="int" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="properties" type="string" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="geom" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
'''))
xml = etree.parse(StringIO('''\
<wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs">
<wfs:Insert>
<feature:cities xmlns:feature="http://www.tinyows.org">
<feature:geom>
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326">
<gml:pos>37.935083007812 55.4423828125</gml:pos>
</gml:Point>
</feature:geom>
</feature:cities>
</wfs:Insert>
</wfs:Transaction>'''))
schema = etree.XMLSchema(schema_doc)
schema.assertValid(xml)
ここでエラーが発生します:
lxml.etree.DocumentInvalid: Element '{http://www.tinyows.org}cities': This element is not expected. Expected is one of ( {http://www.opengis.net/gml}_Feature, http://www.opengis.net/gml}FeatureCollection, {http://www.opengis.net/gml}MultiPointCoverage, {http://www.opengis.net/gml}MultiCurveCoverage, {http://www.opengis.net/gml}MultiSurfaceCoverage, {http://www.opengis.net/gml}MultiSolidCoverage, {http://www.opengis.net/gml}GridCoverage, {http://www.opengis.net/gml}RectifiedGridCoverage, {http://www.opengis.net/gml}Observation, {http://www.opengis.net/gml}DirectedObservation )., line 3
機能はスキーマcities
の代わりに定義されているので、それは私には不可解に思えます。gml:_Feature
おそらく答えはhttp://schemas.opengis.net/wfs/1.1.0/wfs.xsd内にあるはずですが、検証のロジックを理解することはできません。