xml模式 [英] xml schema

查看:74
本文介绍了xml模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[代码]
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd","4.6.1055.0")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code"))
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true,命名空间="http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")]
       公共局部类IfcSweptAreaSolidSweptArea
        {

           私有IfcProfileDef itemField;

            ///<备注/>
            [System.Xml.Serialization.XmlElementAttribute("IfcRectangleProfileDef",typeof(IfcRectangleProfileDef),IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcArbitraryClosedProfileDef",typeof(IfcArbitraryClosedProfileDef),IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcArbitraryOpenProfileDef",typeof(IfcArbitraryOpenProfileDef),IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcCompositeProfileDef",typeof(IfcCompositeProfileDef),IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcDerivedProfileDef",typeof(IfcDerivedProfileDef),IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcProfileDef",typeof(IfcProfileDef),IsNullable = true)]
           公开的IfcProfileDef项
            {
               得到
                {
                   返回this.itemField;
                }
               设置
                {
                    this.itemField =值;
                }
            }
        }
[/code]
我在xsd
生成的一系列类中拥有这段代码            公开的IfcProfileDef项
            {
               得到
                {
                   返回this.itemField;
                }
               设置
                {
                    this.itemField =值;
                }
            }
        }

我尝试从xml获取,并且在xml中是正确的  IfcRectangleProfileDef,它是从ifcProfileDef派生的另一个类,然后
是否可以添加从ifcprofiledef继承的所有类,而ifcprofiledef是所有配置文件的基类,而无需添加所有具体配置文件?
这是我的主要问题,我会对xsd/classes/ndivsp;

[code]
 [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
        [System.SerializableAttribute()]
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.ComponentModel.DesignerCategoryAttribute("code")]
        [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")]
        public partial class IfcSweptAreaSolidSweptArea
        {

            private IfcProfileDef itemField;

            /// <remarks/>
            [System.Xml.Serialization.XmlElementAttribute("IfcRectangleProfileDef", typeof(IfcRectangleProfileDef), IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcArbitraryClosedProfileDef", typeof(IfcArbitraryClosedProfileDef), IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcArbitraryOpenProfileDef", typeof(IfcArbitraryOpenProfileDef), IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcCompositeProfileDef", typeof(IfcCompositeProfileDef), IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcDerivedProfileDef", typeof(IfcDerivedProfileDef), IsNullable = true)]
            [System.Xml.Serialization.XmlElementAttribute("IfcProfileDef", typeof(IfcProfileDef), IsNullable = true)]
            public IfcProfileDef Item
            {
                get
                {
                    return this.itemField;
                }
                set
                {
                    this.itemField = value;
                }
            }
        }
[/code]
i have this piece of code in a series of classes generated by an xsd
            public IfcProfileDef Item
            {
                get
                {
                    return this.itemField;
                }
                set
                {
                    this.itemField = value;
                }
            }
        }

i try to get from xml , and in the xml is correct a  IfcRectangleProfileDef that is another class that derives from ifcProfileDef, then
Is possible to add all the classes that inherits from ifcprofiledef that is the base class of all profiles without add all concrete profiles?
It's my principal problem that i would understand of xsd / classes 

推荐答案

有所了解.可以添加从ifcprofiledef继承的所有类,即所有配置文件的基类,而不添加所有具体配置文件?

您可以创建一个包含方法/行为的抽象类,其中所有具体类都可以从该抽象类派生,并且它们可以访问该抽象类中的方法/行为.

You can have an abstract class with methods/behavior in it that all concrete classes can be derived from the abstract class, and they can access the methods/behavior in the abstract class.

http://www.dotnettricks.com/learn/designpatterns/abstract-factory-design-pattern-dotnet

http://www.dotnettricks.com/learn/designpatterns/abstract-factory-design-pattern-dotnet


这篇关于xml模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆