Xml XSD架构目标命名空间
我试图建立一个新的gml特性模式,但是我认为我误解了名称空间。这是我的模式:Xml XSD架构目标命名空间,xml,namespaces,schema,gml,ogc,Xml,Namespaces,Schema,Gml,Ogc,我试图建立一个新的gml特性模式,但是我认为我误解了名称空间。这是我的模式: <xs:schema targetNamespace="http://localhost/dar" xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/dar"> <xs:import namespace="http://www.openg
<xs:schema targetNamespace="http://localhost/dar" xmlns:gml="http://www.opengis.net/gml" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://localhost/dar">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd" />
<xs:element name="Region" substitutionGroup="gml:_Feature">
<xs:complexType>
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="regionId" type="xs:string" />
<xs:element name="regionName" type="xs:string" />
<xs:element ref="gml:Polygon" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
这是我的测试xml文档:
<wfs:FeatureCollection xmlns="http://localhost/dar" xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://localhost/dar http://localhost/dar/DariusFeatures.xsd
http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
<gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#63266405">
<gml:lowerCorner>10 10</gml:lowerCorner>
<gml:upperCorner>20 20</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<Region>
<regionId>region432762</regionId>
<regionName>Southern Block</regionName>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:coordinates>38.324,21.754 38.424,21.754 38.424,21.854 38.324,21.854 38.324,21.754 </gml:coordinates>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</Region>
</gml:featureMember>
10 10
20 20
地区432762
南区块
38.324,21.754 38.424,21.754 38.424,21.854 38.324,21.854 38.324,21.754
现在模式在eclipse中验证得很好,但是当我尝试验证xml文档时,eclipse告诉我模式文件的目标名称空间为“null”
可以看出,我已经在localhost
上部署了该模式。
有人看到我把事情弄糟了吗?简短版本:您需要将
elementFormDefault=“qualified”
添加到xs:schema
元素中
更长的版本:默认情况下,只有模式中的顶级元素声明进入目标命名空间,嵌套在复杂类型中的元素不会被声明到命名空间中。因此,当前编写的模式要求
regionName
和regionId
不在名称空间中,但XML文档在http://localhost/dar
名称空间。elementFormDefault
会使嵌套的“local”元素也具有目标命名空间。尝试将以下行添加到xml架构中:
<xs:import namespace="http://www.opengis.net/wfs" schemaLocation="http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" />
考虑到这一行(正如Ian所说,xs:schema中的elementFormDefault=“qualified”),xml应该进行验证。好了,已经过了好几天,验证问题仍然是个谜。 作为一种解决方法,我发现OGC的Web功能服务有一个更新版本,位于: 它使用gml 3.2而不是gml 3.1.1
小改动后使用这种新格式一切都好 为什么您的模式根目录中有xmlns=“”?谢谢,您的权限不需要,但这不是问题所在,我已经删除了它,但仍然收到相同的验证错误您的示例无效,您缺少一个结束标记。这很有意义,但我在刷新的eclipse中添加了elementFormDefault=“qualified”,我仍然得到相同的验证错误,即目标名称空间为null,还有其他建议吗?@user143278我注意到您没有
http://www.opengis.net/gml
在xsi:schemaLocation
中列出的名称空间,可能这就是它抱怨的地方。这是不需要的,因为它内部导入很糟糕,没有帮助,此外,我不认为它有什么帮助,因为_Feature元素位于gml名称空间之下,wfs只是利用了它