我正在编辑 eclipse 中的 XSD 文件。保存时,eclipse 会不断从我的文件中删除必要的导入。为什么?这种现象并非在每个 XSD 上都会发生,所以我假设我这边有一个错误。
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="abc"
xmlns:kei="kdf"
xmlns:neo="neoNS"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0"
>
<xsd:import namespace="kdf" schemaLocation="mycomp.kdf.xsd" />
<!-- the next one gets removed on save -->
<xsd:import namespace="neoNS" schemaLocation="mycomp.anExistingFile.xsd" />
<!-- ****************************************************************** -->
<xs:complexType name="initialisiereAngebotType">
<xs:sequence>
<xs:element ref="kei:messageHeader"/>
<xs:element name="payload" type="neo:initialisiereAngebotRequestType"/>
</xs:sequence>
</xs:complexType>
</xsd:schema>
我甚至可以使用 Ctrl+LMB 跳转到现有文件。我需要导入有效负载元素,那么为什么要删除它?
可能与此选项有关:
Window > Preferences > XML > XML Schema Files > Editor
Automatically remove unused XSD imports and XML Namespace entries
尝试取消选中它,看看是否有效。