2013-04-28 41 views
0

我使用xsd.exe將CDA xsd序列化爲csharp類,並試圖構建CCD文檔。該文檔必須通過驗證過程(http://xreg2.nist.gov/cda-validation/validation.html),並且因爲一個元素沒有正確序列化而失敗。xsi:type =將不會正確序列化

任何幫助將非常感謝如何使其工作!謝謝!

我需要它包含xsi:type =「PIVL_TS」,但由於某些原因它不包含。

<effectiveTime xsi:type="PIVL_TS"> 
    <period value="6" unit="h"/> 
</effectiveTime> 

我得到的生成類似於下面

[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:hl7-org:v3")] 
    public partial class PIVL_TS : SXCM_TS { 

     private IVL_TS phaseField; 

     private PQ periodField; 

     private string alignmentField; 

     private bool institutionSpecified1Field; 

     public PIVL_TS() { 
      this.institutionSpecified1Field = false; 
     } 

     /// <remarks/> 
     public IVL_TS phase { 
      get { 
       return this.phaseField; 
      } 
      set { 
       this.phaseField = value; 
      } 
     } 

     /// <remarks/> 
     public PQ period { 
      get { 
       return this.periodField; 
      } 
      set { 
       this.periodField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlAttributeAttribute()] 
     public string alignment { 
      get { 
       return this.alignmentField; 
      } 
      set { 
       this.alignmentField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlAttributeAttribute("institutionSpecified")] 
     [System.ComponentModel.DefaultValueAttribute(false)] 
     public bool institutionSpecified1 { 
      get { 
       return this.institutionSpecified1Field; 
      } 
      set { 
       this.institutionSpecified1Field = value; 
      } 
     } 
    } 

回答

1

我發現,如果我改變了父類類型ANY []它想補充一點,而不是

<effectiveTime> 
    <period value="6" unit="h"/> 
</effectiveTime> 

的CSHARP類我需要的。請參閱下面的註釋代碼。

public partial class POCD_MT000040SubstanceAdministration { 

     private CS[] realmCodeField; 

     private POCD_MT000040InfrastructureRoottypeId typeIdField; 

     private II[] templateIdField; 

     private II[] idField; 

     private CD codeField; 

     private ED textField; 

     private CS statusCodeField; 

     //private PIVL_TS[] effectiveTimeField; 
     private ANY[] effectiveTimeField; 
相關問題