2012-11-15 65 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

後小變化使用這種新的格式萬物精!

相關問題