I went through many SO questions however not found suitable for my situation.
I need to develop a XML generator based on the XSD I am having. User will pass data from UI and that data I need to add in XML tags and pass that file to som ethird party API.
I am having 20 different types of XML files which I need to create based on the users input. e.g. RPC, CSN are file type which user will pass based on that I need to generate XML.
till now I come up with factory design pattern
which will serve me object based on the type user pass from UI (RPC,CSN). What I am not able to undestand is that how can I make this XML file generator generic so that whichever type of file I pass it will cater that request and generate XML for me.
Note: i am having 20 types of files and each file having different tags associated with it.
Factory Pattern I implemented till now:
public static IGenerateXML GetXMLRequestNode(string xmlNode)
{
IGenerateXML generateXMLFactory = null;
if (xmlNode.Equals("RPC"))
{
generateXMLFactory = new RPCFileManager();
}
if (xmlNode.Equals("CSN"))
{
generateXMLFactory = new CSNFileManager();
}
return generateXMLFactory;
}
private static Party_DSParty GetPartyTag(string partyId, string partyType)
{
var partyDSObj = new Party_DSParty();
partyDSObj.Party_ID = new Party_DSPartyParty_ID();
partyDSObj.Party_ID.Party_Id = partyId;
partyDSObj.Party_Type = partyType;
return partyDSObj;
}
this tag I am creating from XSD file model object.
please suggest some generic way how can I generate XML file which we can reuse in most cases.
Aucun commentaire:
Enregistrer un commentaire