gpt4 book ai didi

xml - XSD 架构目标命名空间

转载 作者:行者123 更新时间:2023-12-04 16:51:57 25 4
gpt4 key购买 nike

我正在尝试设置一个新的 gml Feature 模式,但是我认为我对命名空间有一些误解。这是我的架构:

<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 上部署了架构.
谁能看到我哪里搞砸了?

最佳答案

尝试将以下行添加到您的 xml 架构中:

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

鉴于该行(以及 xs:schema 中的 elementFormDefault="qualified",正如 Ian 所说),xml 应该验证。

关于xml - XSD 架构目标命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13393846/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com