gpt4 book ai didi

java - 如何在 Netbeans 8.2 中使用 XSD 1.1?

转载 作者:行者123 更新时间:2023-12-02 11:03:14 25 4
gpt4 key购买 nike

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">

最佳答案

这完全取决于您所说的“在 NetBeans 8.2 中使用 XSD 1.1” 的含义,但我假设您希望在 NetBeans 中使用上下文菜单条目验证 XML具有 XSD 1.1 功能(例如 assert)的 *.xsd 文件。如果我这样做,我会看到您报告的相同的“cvc-complex-type.2.4.a:找到无效内容...”错误。

无法自定义 Validate XML 命令使用的 validator ,显然它使用 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 的解决方案。

关于java - 如何在 Netbeans 8.2 中使用 XSD 1.1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51173771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com