المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Hoe to include a schema reference in an xml file



C# Programming
08-24-2009, 01:32 PM
hi,
My requirement is pretty simple. I need to generate an xml file using C# which will refer some 3 or 4 schema files. Ill have to generate an xml file by including all the schema files and finally validating the generated xml file with all the schema files for any errors.

The problem im facing currenlty is like this:

I have an xsd file named common.xsd and another one called hardwarecommon.xsd.

Every time when i try to write a tag which is defined in common.xsd ill have to include a prefix "c:"

That is if i want to write a tag called "UUT". But this type is defined in common.xsd then ill write it as "C:UUT". When i try writing like this im not able to get the prefix in the xml file. I don see any error but im getting as "UUT" alone. Pls someone help

This is the code im using to generate.

xmldoc = new XmlDocument();
xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
xmldoc.AppendChild(xmlnode);
//adding the root element
xmlelem = xmldoc.CreateElement("", "TestDescription", "");
xmlelem.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlelem.SetAttribute("xmlns:c", "urn:IEEE-1671:2008.01:Common");
xmlelem.SetAttribute("xmlns:hc", "urn:IEEE-1671:2008.01:HardwareCommon");
xmlelem.SetAttribute("xmlns", "urn:P-IEEE-1671.1:2008.03:TestDescription");
xmlelem.SetAttribute("xmlns:tsf", "STDTSFLib");
xmlelem.SetAttribute("xmlns:std","STDBSC");
//xmlelem.SetAttribute("xmlns:atsf", "urn:P-IEEE-1671.1:2008.01:ATMLTSFLib");

xmlelem.SetAttribute("xsi:schema********", "urn:P-IEEE-1671.1:2008.03:TestDescription TestDescription.xsd STDBSC STDBSC.xsd STDTSFLib STDTSFLib.xsd urn:P-IEEE-1671.1:2008.01:ATMLTSFLib ATMLTSFLib.xsd");
xmlelem.SetAttribute("uuid", "{F9ED240A-ABA1-447e-BBBA-1A4EF0D434B1}");

XmlElement Element1 = xmldoc.CreateElement("UUTDescription");
XmlElement Element2 = xmldoc.CreateElement("Description");
XmlElement Element3 = xmldoc.CreateElement("c"+":"+"Identification");

Regards
Jayaraman