xml - How to merge two xsd content into one in C# -
i have 2 xsd files content in dictionary. want merge both contents , create 1 xsd file.
1st xsd content dictionary has import tag pointing 2nd xsd in dictionary.
1st 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>
2nd sxd -
<?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"> // content here </xs:element> </xs:schema>
desired xsd want merger of both xsd documents.
i next : http://msdn.microsoft.com/en-us/library/ms256237%28v=vs.110%29.aspx article, able add together schemas schemaset object also, when using recurseexternals function (from article) not showing merged xsd 2 different xsd.
my block of code -
xmlschemaset schemaset = new xmlschemaset(); // prevents schemalocation , namespace warnings // @ point have schema schemalocation. //schemaset.xmlresolver = null; schemaset.validationeventhandler += new validationeventhandler(validationcallback); // add together schema in schema set 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 main schema schemaset include // other schemas in 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);
am doing wrong ?
c# xml xsd schema xmlschemaset
No comments:
Post a Comment