2012-11-15 69 views
2

我试图设置一个新的gml特性架构,但是我认为我误解了某些名称空间。我的继承人模式:XSD架构目标名称空间

<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> 

现在的模式验证在eclipse罚款但是当我尝试验证XML文档, eclipse告诉我模式文件的目标命名空间是“null”?

可以看出我已经在localhost上部署了架构。 任何人都可以看到我弄乱了吗?

+0

为什么你的schema根中有xmlns =“http:// localhost/dar”? – Eric

+0

谢谢,你的权利多数民众赞成在不需要,但它不是问题,我已经删除它,我仍然得到相同的验证错误 – user143278

+0

您的示例是无效的,你缺少关闭' '标签。 – user27874

回答

0

简短版本:您需要将elementFormDefault="qualified"添加到您的xs:schema元素中。

更长版本:默认情况下,只有模式中的顶级元素声明进入目标名称空间,嵌套在复杂类型中的元素不会声明为名称空间。因此,当前写入的模式预计regionNameregionId不在名称空间中,但您的XML文档在http://localhost/dar名称空间中包含它们。 elementFormDefault也会导致嵌套的“本地”元素承担目标名称空间。

+0

这很有道理,但是我添加了elementFormDefault =“qualified”到http://localhost/dar/DariusFeatures.xsd,刷新了eclipse,并且仍然得到了与目标命名空间为null的相同验证错误,还有其他建议吗? – user143278

+0

@ user143278我注意到你没有在'xsi:schemaLocation'中列出的'http:// www.opengis.net/gml'命名空间,也许这就是它的抱怨。 –

+0

多数民众赞成多数民众赞成不需要,因为http://schemas.opengis.net/wfs/1.1.0/wfs.xsd在内部导入 – user143278

1

尝试下面的行添加到您的XML模式:

<xs:import namespace="http://www.opengis.net/wfs" schemaLocation="http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" /> 

鉴于线(和将elementFormDefault =在XS “合格”:模式,为伊恩说),XML应该验证。

+0

对不起,没有帮助,也没有看到它是如何帮助,因为_Feature元素下gml命名空间,wfs只是利用它 – user143278

0

那么,它已经好几天了,验证问题仍然是一个谜。 由于周围的工作,我发现那里有OGC的Web服务功能的一个新版本: http://schemas.opengis.net/wfs/2.0/wfs.xsd 它采用GML 3.2代替GML 3.1.1

后小变化使用这种新的格式万物精!

相关问题