【问题标题】:xsi:type= wont serialize properlyxsi:type= 不会正确序列化
【发布时间】:2013-04-28 20:10:30
【问题描述】:

我使用 xsd.exe 将 CDA xsd 序列化为 csharp 类,并尝试构建一个 CCD 文档。该文档必须通过验证过程 (http://xreg2.nist.gov/cda-validation/validation.html) 并且由于一个元素未正确序列化而失败。

任何关于如何使其工作的帮助将不胜感激!谢谢!

我需要它包含 xsi:type="PIVL_TS" 但由于某种原因它没有。

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

我得到了这个

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

生成的 csharp 类如下所示

    [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;
            }
        }
    }

【问题讨论】:

    标签: xml xml-serialization cda


    【解决方案1】:

    我发现如果我将父类更改为 ANY[] 类型,它会添加我需要的内容。请参阅下面的注释代码。

     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;
    

    【讨论】:

      猜你喜欢
      • 2011-05-21
      • 1970-01-01
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2015-07-10
      相关资源
      最近更新 更多