簡體   English   中英

如何在不更改 xds 文件的情況下從 CDA 模式創建 POJO 類?

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

我有一個大型 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

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>

到目前為止,我可以找到解決方案( 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM