我正在使用 JDK 7 在 IDEA 13.02 中试用 XML SCHEMA 1.1
这是我从教程中获得的 XML 模式代码。当我在 IntelliJ IDEA 中打开此文件并单击“验证”时,我收到以下错误:
cvc-complex-type.2.4.a:发现以元素“openContent”开头的无效内容。 '{" http://www.w3.org/2001/XMLSchema ":annotation, " http://www.w3.org/2001/XMLSchema ":simpleContent, " http://www.w3.org/2001/XMLSchema ":complexContent, " http://www.w3.org/2001/XMLSchema ":group, " http://www.w3.org/2001/XMLSchema ":all, "之一 http://www.w3.org/2001/XMLSchema ":choice, " http://www.w3.org/2001/XMLSchema ":sequence, " http://www.w3.org/2001/XMLSchema ":attribute, " http://www.w3.org/2001/XMLSchema ":attributeGroup, " http://www.w3.org/2001/XMLSchema ":anyAttribute}' 是预期的。
这是使用 XML Schema 1.1 增强的 XSD 文件:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.books.org"
xmlns:pub="http://www.books.org"
elementFormDefault="qualified">
<complexType name="Publication" abstract="true">
<openContent mode="interleave">
<any />
</openContent>
<sequence>
<element name="Title" type="string" />
<element name="Author" type="string" />
<element name="Date" type="gYear"/>
</sequence>
</complexType>
<complexType name="BookPublication">
<complexContent>
<extension base="pub:Publication">
<openContent mode="none">
</openContent>
<sequence>
<element name="ISBN" type="string"/>
<element name="Publisher" type="string"/>
</sequence>
</extension>
</complexContent>
</complexType>
<element name="BookStore">
<complexType>
<sequence>
<element name="Book" type="pub:BookPublication" maxOccurs="unbounded" />
</sequence>
</complexType>
</element>
</schema>
有没有办法验证或升级 IDEA 使用的验证器?
尝试将
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
和vc:minVersion="1.1"
添加到<schema>
:它将通知 IDEA 您正在使用 XSD 1.1 Schema。
我已经将 XSD 1.1 与 WebStorm 8 一起使用,我相信它使用与 IDEA 相同的解析器。