您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

JAXB-属性“值”已定义。用 解决这个冲突

JAXB-属性“值”已定义。用 解决这个冲突

答案在于利用JAXB绑定(site-template.xjb):

<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
          xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          version="2.1">
    <bindings schemaLocation="site-template.xsd" version="1.0">
        <!-- Customise the package name -->
        <schemaBindings>
            <package name="com.example.schema"/>
        </schemaBindings>

        <!-- rename the value element -->
        <bindings node="//xs:complexType[@name='MetaType']">
            <bindings node=".//xs:attribute[@name='Value']">
                <property name="ValueAttribute"/>
            </bindings>
        </bindings>
    </bindings>
</bindings>

XPath表达式查找节点并重命名节点,从而避免了命名冲突。

使用此绑定XML文件生成java类最终具有所需的getValueAttribute()(以及getValue())。

其他 2022/1/1 18:14:39 有567人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶