Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.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# 如何在C中将两个xsd内容合并为一个#_C#_Xml_Xsd_Schema_Xmlschemaset - Fatal编程技术网

C# 如何在C中将两个xsd内容合并为一个#

C# 如何在C中将两个xsd内容合并为一个#,c#,xml,xsd,schema,xmlschemaset,C#,Xml,Xsd,Schema,Xmlschemaset,我在字典中有2个xsd文件内容。我想合并这两个内容并创建一个xsd文件 字典中的第一个xsd内容具有指向字典中第二个xsd的导入标记 第一个xsd- <?xml version="1.0" encoding="IBM437"?> <xs:schema xmlns:tns="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/EnrichedMessageXML" targetNamespace="http:

我在字典中有2个xsd文件内容。我想合并这两个内容并创建一个xsd文件

字典中的第一个xsd内容具有指向字典中第二个xsd的导入标记

第一个xsd-

<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:tns="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/EnrichedMessageXML"         targetNamespace="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006/Enr
 ichedMessageXML" xmlns:xs="http://www.w3.org/2001/XMLSchema">

 <xs:import schemaLocation="COMP.EDI._00401._810.Schemas.Headers" namespace="http://EDI/Headers" />

 <xs:element name="X12EnrichedMessage">
   <xs:complexType>
    <xs:sequence>
     <xs:element xmlns:q1="http://EDI/Headers" ref="q1:Headers" />
      <xs:element name="TransactionSet">
      <xs:complexType>
        <xs:sequence>
          <xs:element xmlns:q2="http://schemas.microsoft.com/BizTalk/EDI/X12/2006" ref="q2:X12_00401_810" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  </xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我做错什么了吗

<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://EDI/Headers" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://EDI/Headers">

    <xs:element name="Headers">

 // Some content here     

    </xs:element>
</xs:schema>
  XmlSchemaSet schemaSet = new XmlSchemaSet();

  // This prevents schemaLocation and Namespace warnings
  // at this point we already have the schema from schemaLocation.
  //schemaSet.XmlResolver = null;

  schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);

  // add schema in schema set from schemacollection object
  foreach (var item in schemaCollection)
  {
      schemaSet.Add(item.Key, new XmlTextReader(new StringReader(item.Value)));
  }

  schemaSet.Compile();

  XmlSchema mainXmlSchema = null;

  XmlSchemaImport import = new XmlSchemaImport();
  foreach (XmlSchema sch in schemaSet.Schemas())
  {
      // pick the main schema from the schemaset to include
      // other schemas in the collection.
      if (sch.TargetNamespace == mainSchemaNS)
      {
          mainXmlSchema = sch;
      }
      else
      {
          import.Namespace = sch.TargetNamespace;
          import.Schema = sch;
          mainXmlSchema.Includes.Add(import);
      }
  }

  schemaSet.Reprocess(mainXmlSchema);
  schemaSet.Compile();

  RecurseExternals(mainXmlSchema);