问题陈述我定义了以下 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>到目前为止我尝试了什么?
1 回答
SMILET
TA贡献1796条经验 获得超4个赞
最后,解决方案如下:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="1.0">
<jaxb:bindings schemaLocation="../xsd/mdml/com/mycompany/mds/mdml/schema/xc.xsd"
node="//xs:attributeGroup[@name='valueAtt']/xs:attribute[@name='value']">
<jaxb:property name="ValueAttribute"/>
</jaxb:bindings>
</jaxb:bindings>
基本上这是我的尝试 3,将属性名称用单引号括起来。
添加回答
举报
0/150
提交
取消