处理 LibXML2 XSD Schema GML 错误¶
问题¶
TinyOWS 使用了基于XML的几何编码语言GML。TinyOWS 的输入和输出通常采用GML。
即使libxml2是一个伟大的lib,旧版本(即2.8之前的版本)也没有正确处理 GML 3.1.1 XSD 模式 (see https://bugzilla.gnome.org/show_bug.cgi?id=630130)。
解决方法和选项¶
对于Tinyows用户,您有几个选项
采用最新的libxml2版本(即2.8或更高版本)
修补libxml2版本的最旧副本,并将tinyows链接到本地副本:
--- xmlschemas.c.orig 2011-04-24 14:58:16.000000000 +0000
+++ xmlschemas.c 2011-04-24 15:47:50.000000000 +0000
@@ -15158,7 +15158,11 @@
}
if ( (WXS_IS_LIST(type) || WXS_IS_UNION(type)) &&
(WXS_IS_RESTRICTION(type) == 0) &&
- (! WXS_IS_ANY_SIMPLE_TYPE(baseType))) {
+ (
+ (! WXS_IS_ANY_SIMPLE_TYPE(baseType))
+ && (baseType->type != XML_SCHEMA_TYPE_SIMPLE)
+ )
+ ) {
xmlSchemaPCustomErr(ctxt,
XML_SCHEMAP_ST_PROPS_CORRECT_1,
WXS_BASIC_CAST type, NULL,
}}}
修改XSD GML模式本身(但如果这样做,将违反OGC许可证!):
Index: schema/gml/3.1.1/base/valueObjects.xsd
===================================================================
--- schema/gml/3.1.1/base/valueObjects.xsd (revision 550)
+++ schema/gml/3.1.1/base/valueObjects.xsd (revision 561)
@@ -200,11 +200,13 @@
<group name="ValueExtent">
<choice>
+<!--
<element ref="gml:CategoryExtent"/>
<element ref="gml:QuantityExtent"/>
+-->
<element ref="gml:CountExtent"/>
</choice>
</group>
- <!-- ======================================================================
- <element name="QuantityExtent" type="gml:QuantityExtentType" substitutionGroup="gml:_Value"> -->
+ <!-- ======================================================================
+ <element name="QuantityExtent" type="gml:QuantityExtentType" substitutionGroup="gml:_Value">
<element name="QuantityExtent" type="gml:QuantityExtentType">
<annotation>
@@ -212,5 +214,4 @@
</annotation>
</element>
- <!-- -->
<complexType name="QuantityExtentType">
<annotation>
@@ -223,6 +224,7 @@
</simpleContent>
</complexType>
+-->
<!-- ======================================================================
- <element name="CategoryExtent" type="gml:CategoryExtentType" substitutionGroup="gml:_Value"> -->
+ <element name="CategoryExtent" type="gml:CategoryExtentType" substitutionGroup="gml:_Value">
<element name="CategoryExtent" type="gml:CategoryExtentType">
<annotation>
@@ -230,5 +232,4 @@
</annotation>
</element>
- <!-- -->
<complexType name="CategoryExtentType">
<annotation>
@@ -241,4 +242,5 @@
</simpleContent>
</complexType>
+-->
<!-- ======================================================================
<element name="CountExtent" type="gml:CountExtentType" substitutionGroup="gml:_Value"> -->
或同时选择仅使用GML 2.1.2。