如何在 Netbeans 8.2 中使用 XSD 1.1?

How to use XSD 1.1 in Netbeans 8.2?

Netbeans 似乎拒绝 XSD 1.1 支持的一些 XSD 标签,例如 "assert":

cvc-complex-type.2.4.a : Invalid content found from the element 'xs:assert'. One of the values '{"http://www.w3.org/2001/XMLSchema":attribute, "http://www.w3.org/2001/XMLSchema":attributeGroup, "http://www.w3.org/2001/XMLSchema":anyAttribute}' is expected. [205]

我尝试使用一些 these examples 但没有成功。我该怎么做才能解决我的问题?

据我所知,我无需在 XSD 架构中指定我使用 XSD 1.1:

的某些功能
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

这完全取决于你所说的 "use XSD 1.1 in NetBeans 8.2" 的意思,但我假设你想使用上下文菜单条目 Validate XML 在 NetBeans 中针对某些 *.xsd 具有 XSD 1.1 功能的文件(例如 assert) .如果我这样做,我会看到与您报告的相同的 "cvc-complex-type.2.4.a : Invalid content found..." 错误。

无法自定义 Validate XML 命令使用的验证器,显然它使用 JDK 的 javax.xml API 进行验证。 NetBeans 8.2 使用 Java 8,但 even with JDK 9 there is no way to validate XSD 1.1 features:

Java 9.

...The big news is that finally we get the internal ports of Xerces updated. Oracle (and Sun before them) have been really slack in neglecting this so long: Java was stuck using Xerces 2.7.n for 11 years for goodness sake. The new ports are equivalent to Apache Xerces 2.11.0. (NOTE: XSD is still 1.0 only, the XSD 1.1 updates have not been put in place, but this probably reflects Apache Xerces’ slow pace to make the changes official.)

使用 Apache NetBeans 9.0 RC1 时会出现同样的问题,所以这个问题可能不会得到解决,直到:

  • NetBeans 使用 JDK,它使用支持验证 XSD 1.1 功能的 Xerces 版本。
  • NetBeans 使用不同的方法进行 XSD 验证。

我也没有看到任何有用的 NetBeans 插件。当然,Maven 项目的第三方工具和(可能)配置可能会有所帮助,但我没有看到仅使用 NetBeans 的解决方案。