I have done sequence diagram and transform it to an XML file, then I have developed parser using C# to extract the test cases from that XML file, but still, the parser not working well, how can I extract the exact tags and elements I need for generating test cases?
this is for c# console application visual studio 2017.
public XDocument GetDiagramXml(string diagramName, string diagramXmlFile) { XNamespace UML = "omg.org/UML1.3"; XDocument diagramElements = XDocument.Load(diagramXmlFile); XElement test = XElement.Load(diagramXmlFile); IEnumerable<XElement> elements = diagramElements.Descendants("XMI.content"); foreach (XElement element in elements) { XElement xmiElement2 = element.Element(UML + "Diagram"); XElement xmiElement3 = null; if (xmiElement2.Attribute("name").Value == diagramName) xmiElement3 = xmiElement2.Element(UML + "Diagram.element"); var output = xmiElement3.Descendants(UML + "DiagramElement"); diagramElements = XDocument.Load(xmiElement3.CreateReader()); } return diagramElements; } public Dictionary<string, string> GetDiagramElments(XDocument diagramRawXml) { Dictionary<string, string> diagramExtractedElements = new Dictionary<string, string>(); return diagramExtractedElements; } public Dictionary<string, Dictionary<string, string>> GetDiagramMessages(Dictionary<string, string> diagramExtractedElement, string diagramXmlFile) { Dictionary<string, Dictionary<string, string>> messagesList = new Dictionary<string, Dictionary<string, string>>(); return messagesList; }
the actual result is must be the test cases generated from the sequence diagram.
Asked
Active
Viewed 219 times
-2

bruno
- 32,421
- 7
- 25
- 37
-
How do you think someone could give you help based on the information provided? "Help, it won't work" won't work. Go and read the help pages to find out what kind of questions are regarded good ones. – qwerty_so Mar 24 '19 at 17:25
1 Answers
0
having
XNamespace UML = "omg.org/UML1.3"; ... XElement xmiElement2 = element.Element(UML + "Diagram"); ... xmiElement3 = xmiElement2.Element(UML + "Diagram.element"); ... var output = xmiElement3.Descendants(UML + "DiagramElement");
you do
XElement xmiElement2 = element.Element("omg.org/UML1.3Diagram"); ... xmiElement3 = xmiElement2.Element("omg.org/UML1.3Diagram.element"); ... var output = xmiElement3.Descendants("omg.org/UML1.3DiagramElement");
probably a '/' is missing and that can be solved doing
XNamespace UML = "omg.org/UML1.3/";
but not sure this is enough to read the elements because all is 'strange'
Visibly you do not read a model file (searching for the interactions), but the file is an UML Diagram Interchange (because of DiagramElement), how can you have UML1.3
? What tool generated it ?
Are you sure you want to work from UML Diagram Interchange ? Are you even sure you want to work from an interaction/sequence diagram ? An interaction is 'limited' because this is not a behavior for instance

bruno
- 32,421
- 7
- 25
- 37
-
ok, I used Enterprise architect to design a sequence diagram and automatically generate an XML file for the sequence using the same tool. what I need is to generate a test case for that sequence through a parser developed using c#. the parser is to read the sequence XML file and extract the tags, values, and elements, then determine the all possible paths. – HUSSAM ALI Apr 03 '19 at 15:29