如何在不更改xds文件的情况下从CDA模式创建POJO类?

问题描述

我有一个很大的CDA架构文件,该文件用于生成CDA xml文档。我想在代码编译期间使用xds模式生成POJO类。 我正在尝试使用jaxb2-maven-plugin做到这一点,如下所示:

           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>myDirectoryName</schemaDirectory>
                    <schemaFiles>myxsdFile</schemaFiles>
                </configuration>
            </plugin>

这似乎适用于简单的xsd文件。但是使用我的CDA会引发错误

无法执行目标org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc 。 。 尝试两次创建相同的字段:id

由于id同时作为元素和属性出现,xsd中正在产生问题的部分如下:

<xs:complexType name="POCD_MT000040.ObservationMedia">
        <xs:sequence>
            <xs:element name="realmCode" type="CS" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="typeId" type="POCD_MT000040.InfrastructureRoot.typeId" minOccurs="0" />
            <xs:element name="templateId" type="II" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="id" type="II" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="languageCode" type="CS" minOccurs="0" />
            <xs:element name="value" type="ED" />
            <xs:element name="subject" type="POCD_MT000040.Subject" minOccurs="0" />
            <xs:element name="specimen" type="POCD_MT000040.Specimen" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="performer" type="POCD_MT000040.Performer2" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="author" type="POCD_MT000040.Author" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="informant" type="POCD_MT000040.Informant12" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="participant" type="POCD_MT000040.Participant2" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="entryRelationship" type="POCD_MT000040.EntryRelationship" minOccurs="0"
                maxOccurs="unbounded" />
            <xs:element name="reference" type="POCD_MT000040.Reference" minOccurs="0" maxOccurs="unbounded" />
            <xs:element name="precondition" type="POCD_MT000040.Precondition" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="ID" type="xs:ID" />
        <xs:attribute name="nullFlavor" type="NullFlavor" use="optional" />
        <xs:attribute name="classCode" type="ActClassObservation" use="required" />
        <xs:attribute name="moodCode" type="ActMood" use="required" />
    </xs:complexType>

到目前为止,我可以找到解决方案, (http://metro.1045641.n5.nabble.com/troubleshoot-quot-trying-to-create-the-same-field-twice-quot-error-td1059643.html)建议对xds进行更改,这对我来说不是一个选择。除了更改xds或使用其他实用程序之外,还有其他方法吗?

解决方法

不确定您的要求,但是无法使用HL7的CDA架构作为典型XML / java技术的一部分-此外,序列化符合Consol等规范的CDA的能力并非易事

我建议使用支持Consol的MDHT API

https://projects.eclipse.org/projects/modeling.mdht

https://github.com/mdht/mdht-models

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...