简体   繁体   English

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

[英]How to create POJO class from a CDA schema without changing the xds file?

I have a large CDA schema file which is used in generation of a CDA xml document.我有一个大型 CDA 模式文件,用于生成 CDA xml 文档。 I want to generate POJO classes using the xds schema during compiling of code.我想在编译代码期间使用 xds 模式生成 POJO 类。 I am trying to do this with jaxb2-maven-plugin as below:我正在尝试使用 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>

This seems to work with simple xsd files.这似乎适用于简单的 xsd 文件。 But with my CDA it throws error但是使用我的 CDA 它会引发错误

Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc .无法执行目标 org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc 。 . . trying to create the same field twice: id尝试两次创建相同的字段:id

The part in xsd which is creating problem, due to id being present both as element as well as attribute..is as below: xsd 中产生问题的部分,由于 id 既作为元素也作为属性存在..如下:

<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>

The solutions for this, so far I could find, ( http://metro.1045641.n5.nabble.com/troubleshoot-quot-trying-to-create-the-same-field-twice-quot-error-td1059643.html ) suggest making changes to the xds which is not an option for me.到目前为止,我可以找到解决方案( http://metro.1045641.n5.nabble.com/troubleshoot-quot-trying-to-create-the-same-field-twice-quot-error-td1059643。 html ) 建议对 xds 进行更改,这对我来说不是一个选项。 Is there a way other than changing xds or using some other utility?除了更改 xds 或使用其他实用程序之外,还有其他方法吗?

Not sure your requirements but CDA schema from HL7 is not usable as part of typical XML/java technologies - Additionally the ability to serialize CDA that is conforms to spec such as Consol is not trivial不确定您的要求,但 HL7 的 CDA 模式不能用作典型 XML/java 技术的一部分 - 此外,序列化符合 Consol 等规范的 CDA 的能力并非微不足道

i would suggest using MDHT api which support Consol我建议使用支持 Consol 的 MDHT api

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM