- 问题描述:
xsd文件列表:
CDA.xsd
PCHIS.xsd
POCD_MT000040.xsd
datatypes.xsd
datatypes-base.xsd
NarrativeBlock.xsd
voc.xsd
cmd下使用jdk自带xjc命令,根据xsd生成java实例对象的时候报错 troubleshoot "trying to create the same field twice" error
- 解决办法:
1.错误在该文件中,打开POCD_MT000040.xsd,查找<xs:attribute name="ID" type="xs:ID"/>
修改为
<!--<xs:attribute name="ID" type="xs:ID"/>-->
<xs:attribute name="ID" type="xs:ID">
<xs:annotation>
<xs:appinfo>
<jaxb:property name="ID1"/>
</xs:appinfo>
</xs:annotation>
</xs:attribute>
总共修改3处。
2.该文件头部加入jaxb命名空间信息
<!--<xs:schema xmlns:mif="urn:hl7-org:v3/mif" xmlns="urn:hl7-org:v3" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:hl7-org:v3" elementFormDefault="qualified">-->
<xs:schema targetNamespace="urn:hl7-org:v3"
xmlns:mif="urn:hl7-org:v3/mif"
xmlns="urn:hl7-org:v3"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
elementFormDefault="qualified"
jaxb:version="2.0"
jaxb:extensionBindingPrefixes="xjc">
3.保存后进入cmd命令,执行xjc -extension CDA.xsd
- 原文请参考:
http://markmail.org/message/yprfd7pkyf2ngqr3
http://metro.1045641.n5.nabble.com/troubleshoot-quot-trying-to-create-the-same-field-twice-quot-error-td1059643.html