如何修复此 XML 架构?

How do I fix this XML schema?

我正在尝试在我的 XML 架构中使用 JAXB 和 IntelliJ Ultimate。这是来自 IndoorGML 网站的架构。但是,IDE 说它有问题。

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  targetNamespace="http://www.opengis.net/indoorgml/1.0/core"
       xmlns:gml="http://www.opengis.net/gml/3.2" elementFormDefault="qualified" version="1.0.3">
<xs:annotation>
    <xs:documentation>
        IndoorGML is an OGC Standard. Copyright (c) 2014,2015,2016,2018 Open Geospatial Consortium. To obtain additional rights of use, visit http://www.opengeospatial.org/legal/.
    </xs:documentation>
</xs:annotation>
<!--
 ======================================================================
-->
<xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
<!--
 ======================================================================
-->
<xs:element name="IndoorFeatures" type="IndoorFeaturesType" substitutionGroup="gml:AbstractFeature"/>
<!--

</xs:schema>

substitutionGroup="gml:AbstractFeature" 的最后一行中,IDE 将 AbstractFeature 标记为红色,并带有消息“无法解析符号 'gml:AbstractFeature'”。有谁知道为什么? (XSD 文件在结束模式标记之前有更多标记,我没有放在这里,因为它有几百行。)

提前致谢! :)

报告的错误是关于这个参考:substitutionGroup="gml:AbstractFeature" ...正在尝试使 'IndoorFeatures' 成为另一个名称空间中定义的替换组的成员。

但是哪个命名空间?由前缀 'gml' 标识的命名空间。那是哪个命名空间?答案在这里:xmlns:gml="http://www.opengis.net/gml/3.2"

因此我们需要找出该命名空间导入到此 XSD 的位置。这是在这里完成的:

<xs:import namespace="http://www.opengis.net/gml/3.2" schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>

我认为错误的原因现在已经很明显了,但我会继续完成答案。定义该名称空间的 XSD 在此处标识: schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"

显然,您的应用程序无法解析 URL 或不允许访问它。

如何解决?

如果你能得到一份 XSD 那么你可以

a) 将其保存到本地文件夹并更改 schemaLocation 属性以指向本地文件夹,或者

b) 定义一个架构解析器,将 URL 映射到您的文件夹位置。

不确定 IntelliJ 是否支持模式解析器,但我希望它支持。