gpt4 book ai didi

java - 使用 xjc 生成类文件时不支持绑定(bind)命名空间

转载 作者:太空宇宙 更新时间:2023-11-04 15:09:35 25 4
gpt4 key购买 nike

我尝试在没有任何帮助的情况下进行谷歌搜索。如有重复,敬请谅解。

我有以下文件 common.xsd 的架构 header

<xs:schema xmlns="http://www.vmware.com/vcloud/v1.5"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:meta="http://www.vmware.com/vcloud/meta"
jaxb:version="2.0"
jaxb:extensionBindingPrefixes="meta"
elementFormDefault="qualified"
targetNamespace="http://www.vmware.com/vcloud/v1.5"
version="1.0">

我正在尝试使用 xjc 命令生成类文件。

xjc -version
xjc version "JAXB 2.1.10 in JDK 6"
JavaTM Architecture for XML Binding(JAXB) Reference Implementation, (build JAXB 2.1.10 in JDK 6)

我收到此错误。

[info] [ERROR] Unsupported binding namespace "http://www.vmware.com/vcloud/meta". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
[info] line 21 of file:/Users/kcherivirala/vmware/dev/corp/zephyr/services/networkservice/app/vcd-schema/src/main/xsd/vcloud/common.xsd

任何有关这方面的线索都会有很大帮助。

最佳答案

问题出在这里:

   jaxb:extensionBindingPrefixes="meta"

jaxb:extensionBindingPrefixes 声明供应商自定义命名空间的前缀。请参阅this link .

The JAXB RI provides additional customizations that are not defined by the JAXB specification. Note the following:

These features may only be used when the JAXB XJC binding compiler is run in the -extension mode.

All of the JAXB RI vendor extensions are defined in the "http://java.sun.com/xml/ns/jaxb/xjc" namespace.

The namespaces containing extension binding declarations are specified to a JAXB processor by the occurrence of the global attribute @jaxb:extensionBindingPrefixes within an instance of element. The value of this attribute is a whitespace-separated list of namespace prefixes. For more information, please refer to section 6.1.1 of the JAXB Specification.

仅当您自定义绑定(bind)时才需要它。例如,您可以使用 xjc:superClass 来自定义以扩展公共(public)父类(super class)。在这种情况下,xjc 将位于 jaxb:extensionBindingPrefixes 中。

如果您只是编译您的架构,您的架构的前缀肯定不会在 jaxb:extensionBindingPrefixes 中。因此,XJC 只是提示它在那里,但不是一个具有约束力的扩展。

关于java - 使用 xjc 生成类文件时不支持绑定(bind)命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21520519/

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