Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 反序列化作为引用的XML元素(RDF资源)_C#_Xml_Serialization_Rdf - Fatal编程技术网

C# 反序列化作为引用的XML元素(RDF资源)

C# 反序列化作为引用的XML元素(RDF资源),c#,xml,serialization,rdf,C#,Xml,Serialization,Rdf,我有一个XML文件,其中一些元素是资源。 像 我正在尝试序列化xml文件,该文件工作正常,但使用as resource EquipmentContainer的元素为空 我不知道如何序列化作为xml资源的xml元素。我在c#中的XML序列化中缺少一些概念,我找不到如何查找帮助/Google这个问题。如果您正在使用RDF,为什么不使用RDF库?RDF可以序列化为XML,但如中所述,有几种方法可以实现。例如,rdf:ID属性可以替换为rdf:about——这可能会破坏解析器 您可能对使用RDF的.Ne

我有一个XML文件,其中一些元素是资源。 像

我正在尝试序列化xml文件,该文件工作正常,但使用as resource EquipmentContainer的元素为空


我不知道如何序列化作为xml资源的xml元素。我在c#中的XML序列化中缺少一些概念,我找不到如何查找帮助/Google这个问题。

如果您正在使用RDF,为什么不使用RDF库?RDF可以序列化为XML,但如中所述,有几种方法可以实现。例如,
rdf:ID
属性可以替换为
rdf:about
——这可能会破坏解析器


您可能对使用RDF的.Net库感兴趣。

不幸的是,XML序列化程序不是序列化和反序列化所有XML的完整工具。在这种情况下,我认为你必须“自己做”。XML序列化程序不处理引用(这里就是引用)。看看。@JohnSaunders谢谢。我花了大量时间开发UML结构和编码。在我遇到这个资源引用问题之前,一切都很好。这应该是一个提示。建模应该穿插在编码、测试和发布中。否则,你会得到一个无法实现的漂亮模型。@JohnSaunders非常正确。
<cim:BusbarSection rdf:ID="Busbar_05" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"       xmlns:cim="http://iec.ch/TC57/2001/CIM-schema-cim10#">
<cim:Naming.name>30189P0205_Busbar_01</cim:Naming.name>
<cim:Equipment.MemberOf_EquipmentContainter rdf:resource="#VL_05" />
</cim:BusbarSection>
<cim:VoltageLevel rdf:ID="VL_05" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:cim="http://iec.ch/TC57/2001/CIM-schema-cim10#">
<cim:Naming.name>VL_0.22_1</cim:Naming.name>
<cim:VoltageLevel.MemberOf_Substation rdf:resource="#Substation_01" />
<cim:VoltageLevel.BaseVoltage rdf:resource="#BaseVoltage_02" /></cim:VoltageLevel>
  [XmlType("BusbarSection", Namespace = "http://iec.ch/TC57/2001/CIM-schema-cim10#")] 
   public class BusbarSection:Connector 
   {
       public BusbarSection()
       {
       }

   }
    public class Connector:Core.ConductingEquipment
   {

      public Connector()
      {
      }

   }
   public class ConductingEquipment:Equipment 
    {
        //functions and constcturess...
    }
    public class Equipment:PowerSystemResource
   {
       [XmlElement("Equipment.MemberOf_EquipmentContainer")]
       public EquipmentContainer MemberOf_EquipmentContainer; 

       public Equipment()
       {
       }

   }

public class EquipmentContainer:PowerSystemResource
{

    public Topology.ConnectivityNode[] ConnectivityNodes;
    public Equipment[] Contains_Equipments; 

    public EquipmentContainer()
    {

    }

}