猿问

属性组 - 属性“值”已定义。使用 <jaxb:property> 来解决这个冲突

问题陈述

我定义了以下 XSD:


<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xc="XmlCache" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:import namespace="XmlCache" schemaLocation="mdml/com/mycompany/mds/mdml/schema/xc.xsd"/>

    <xs:element name="MarketData">

        <xs:complexType>

            <xs:sequence>

                <xs:element ref="xc:XmlCache" minOccurs="0" maxOccurs="1"/>

            </xs:sequence>

        </xs:complexType>

    </xs:element>

</xs:schema>

该元素xc:XmlCache在文件中定义mdml/com/mycompany/mds/mdml/schema/xc.xsd

jaxb我想使用(带插件)基于此 XSD 生成 Java 类jaxb2-maven-plugin

错误

我在编译过程中不断收到以下错误:

[错误] jar:file:/C:/Users/miannizzotto/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.1.13/jaxb-xjc-2.1.13.jar!/com/sun /xml/xsom/impl/parser/datatypes.xsd[14,33] com.sun.istack.SAXParseException2;systemId: jar:file:/C:/Users/miannizzotto/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.1.13/jaxb-xjc-2.1.13.jar!/com/sun/ xml/xsom/impl/parser/datatypes.xsd;行号:14;列数:33;属性“值”已定义。使用 <jaxb:property> 解决此冲突。

其次是

[错误] 文件:/D:/v3.1.build.dev.asset.x.91253.5.4.dev/component/legacy/sdk/product-api/api/src/main/xsd/mdml/com/mycompany /mds/mdml/schema/xc.xsd[57,63] com.sun.istack.SAXParseException2;systemId: 文件:/D:/v3.1.build.dev.asset.x.91253.5.4.dev/component/legacy/sdk/product-api/api/src/main/xsd/mdml/com/mycompany/ mds/mdml/schema/xc.xsd;行号:57;列数:63;以下位置与上述er相关

有罪档案的结构

该文件mdml/com/mycompany/mds/mdml/schema/xc.xsd非常大,但我只在下面放出有罪的部分(第 57 行及其树的主要节点):

<?xml version="1.0"?>

<!DOCTYPE xs:schema>

    ...

    <xs:attributeGroup name="valueAtt">

        <xs:attribute name="value" use="optional" form="qualified"/> <!--this is line 57-->

    </xs:attributeGroup>

    ...

</xs:schema>

到目前为止我尝试了什么?


月关宝盒
浏览 163回答 1
1回答

SMILET

最后,解决方案如下:<?xml version="1.0" encoding="UTF-8"?><jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:xs="http://www.w3.org/2001/XMLSchema"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jaxb:extensionBindingPrefixes="xjc"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;jaxb:version="1.0">&nbsp; &nbsp; <jaxb:bindings schemaLocation="../xsd/mdml/com/mycompany/mds/mdml/schema/xc.xsd"&nbsp; &nbsp; node="//xs:attributeGroup[@name='valueAtt']/xs:attribute[@name='value']">&nbsp; &nbsp; &nbsp; &nbsp; <jaxb:property name="ValueAttribute"/>&nbsp; &nbsp; </jaxb:bindings></jaxb:bindings>基本上这是我的尝试 3,将属性名称用单引号括起来。
随时随地看视频慕课网APP

相关分类

Java
我要回答