Click here to Skip to main content
15,882,055 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there anyone who has an idea of how I can convert flowchart to xml? I need an xml representation of the flowchart. The example of a very simple flowchart will help me get started.

I just need the flowchart to be represented in xml such that i can get the same understanding of the problem from reading xml file instead of looking at the flow chart. That is the xml should be the direct translation of the flowchart.
Posted

Well, you should encode in the XML nodes all the info provided by the flowchart items themselves, namely the shape, the inner text, the (possibly labeled) connections.
 
Share this answer
 
A flowchart is hierarchically structured and XML likewise is hierarchically structured. So what are the difficulties here? I don't know, but you can feel free to add some via a comment. Take an if statement for instance, it consists of a condition, a consequence and an alternative.
So to build this into XML this here seems a valid approach:

XML
<flowchart>
    <if condition="i<1">
	    <consequence>
		    <!-- further XML for the code in the if part -->
		<consequence>
		<alternative>
		    <!-- further XML for the code in the else part -->
		</alternative>
	</if>
</flowchart>

If on the other hand the code inside the condition of the if-statement would become complexer you might make a sepearate tag out of the attribute "condition" like so:

XML
<flowchart>
    <if>
        <condition>
            <!-- further XML for the code of the condition of the if -->
        </condition>
        <consequence>
	    <!-- further XML for the code in the if part -->
	<consequence>
	<alternative>
	    <!-- further XML for the code in the else part -->
	</alternative>
    </if>
</flowchart>


[Modification: Inspired by CPallini's[^] Solution 1[^]]
XML
<flowchart>
    <sequence id="initialization">
        <block id="block1" followRef="block2">
            <!-- further XML for the code for the content of block 1 -->
	    </block>
	    <block id="block2" followRef="block1">
	        <!-- further XML for the code for the content of block 2 -->
	    </block>
    </sequence>
</flowchart>

[End Modification]
The followRef attributes link from one block to another and in this case I even formed a cycle. (Just for instructional purposes though and not so meaningful in this context)
Regards,

— Manfred
 
Share this answer
 
v3
Comments
CPallini 18-Sep-12 6:55am    
The flowchart structure however might be cyclic while XML is not. For this very reason I suggested the OP to include the 'shape connections' as info in the XML nodes.
Manfred Rudolf Bihy 18-Sep-12 7:05am    
I've deleted my previous comment as I've understood what you meant by cyclic!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900