IntelliJ中无法识别XML Schema唯一约束

问题描述 投票:0回答:1

在尝试了许多事情以在IntelliJ中通过一个独特的约束获得错误之后,我开始怀疑IntelliJ是否甚至认识到它。

我试过的最后一个模式来自这篇文章Unique constraint in XML Schema

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.brabantia.com/XMLSchema/ESBConfig"
        xmlns:tns="http://www.brabantia.com/XMLSchema/ESBConfig"
        elementFormDefault="qualified">
    <element name="authors">
        <complexType>
            <sequence>
                <element name="author" maxOccurs="unbounded" type="string"/>
            </sequence>
        </complexType>
        <unique name="uniqueAuthor">
            <selector xpath="author"/>
            <field xpath="."/>
        </unique>
    </element>
</schema>

我曾经用IntelliJ生成XML。

<?xml version="1.0" encoding="UTF-8"?>
<esb:authors xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig">
  <!--1 or more repetitions:-->
  <esb:author>string</esb:author>
  <esb:author>string</esb:author>
  <esb:author>string</esb:author>
</esb:authors>

哪个应该显示错误,但事实并非如此。

Generate Instance Document From Schema巫师我检查了Enable restriction checkEnable unique check

所有其他检查都有效,如枚举和模式。

有人可以告诉我这是架构中的东西还是IntellJ中根本不支持的东西?

intellij-idea xsd xsd-validation
1个回答
2
投票

添加xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig"并更改为<selector xpath="esb:author"/> in your schema

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.brabantia.com/XMLSchema/ESBConfig"
        xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig"
        elementFormDefault="qualified">
    <element name="authors">
        <complexType>
            <sequence>
                <element name="author" maxOccurs="unbounded" type="string"/>
            </sequence>
        </complexType>
        <unique name="uniqueAuthor">
            <selector xpath="esb:author"/>
            <field xpath="."/>
        </unique>
    </element>
</schema>

结果:

Validation result

© www.soinside.com 2019 - 2024. All rights reserved.