微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何在不更改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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。