【发布时间】:2018-03-01 05:03:39
【问题描述】:
在尝试了很多事情以在 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 check 和Enable unique check。
所有其他检查都有效,例如枚举和模式。
有人可以告诉我这是架构中的内容还是 IntellJ 根本不支持的内容?
【问题讨论】:
-
在您的架构中添加
xmlns:esb="http://www.brabantia.com/XMLSchema/ESBConfig"并更改为<selector xpath="esb:author"/>
标签: intellij-idea xsd xsd-validation