I am attempting to take equation logic (from Peoplesoft, for those who are familiar. Specifically "Equation Engine") which was output from the system as XML and parse it so that I can eventually programmatically create a flowchart that visualizes the logic for that particular equation. In the past I have used XMLSerializer within a C# desktop app, but that was when the XML structure could be mapped directly into a class.
In this case, there is branching if/then logic that I would like to capture, as well as variable assignment with mathematical operations included:
<?xml version='1.0'?>
<EQUATION>
<EQUATIONNAME>F5_ADJ_AWD_S</EQUATIONNAME>
<ASSIGN>
<GLOBAL>PER_CREDIT</GLOBAL>
<GLOBAL>GLOBAL_AWARD</GLOBAL>
<OPERATOR>/</OPERATOR>
<VALUE>30</VALUE>
</ASSIGN>
<ASSIGN>
<LOCAL>ORIGINAL_EFA_AY_VALUE</LOCAL>
<COMMENT>Store local version of EFA AY value</COMMENT>
<GLOBAL>GLOBAL_AWARD</GLOBAL>
</ASSIGN>
<ASSIGN>
<GLOBAL>TEMP_VALUE</GLOBAL>
<VALUE>0</VALUE>
</ASSIGN>
<IF>
<GLOBAL>WORK_FIELD_CHAR_05</GLOBAL>
<OPERATOR>=</OPERATOR>
<STRING>SPRING</STRING>
<THEN/>
<COMMENT>Start of Spring section</COMMENT>
<ASSIGN>
<GLOBAL>STRM</GLOBAL>
<STRING>2310</STRING>
<COMMENT>In the spring, the global strm above will be the spring value, so this resets it to fall in order to grab the fall value</COMMENT>
</ASSIGN>
<CALL/>
<EQTN>F1_SEL_BY_IT</EQTN>
<ASSIGN>
<GLOBAL>FALL_VALUE</GLOBAL>
<GLOBAL>TEMP_VALUE</GLOBAL>
</ASSIGN>
<ASSIGN>
<GLOBAL>COMBINED_UNIT_MAX_VALUE</GLOBAL>
<COMMENT>Max value based on per credit times combined units, or remaining Spring eligible value when in Fall mode</COMMENT>
<LOCAL>ORIGINAL_EFA_AY_VALUE</LOCAL>
<COMMENT>AY Value</COMMENT>
<OPERATOR>-</OPERATOR>
<GLOBAL>FALL_VALUE</GLOBAL>
<COMMENT>Fall Value</COMMENT>
</ASSIGN>
<ASSIGN>
<GLOBAL>GLOBAL_AMT</GLOBAL>
<GLOBAL>WORK_FIELD_NUM_01</GLOBAL>
<COMMENT>Spring units</COMMENT>
<OPERATOR>*</OPERATOR>
<GLOBAL>PER_CREDIT</GLOBAL>
</ASSIGN>
<ELSE/>
<COMMENT>Start of Fall section</COMMENT>
<ASSIGN>
<GLOBAL>FALL_VALUE</GLOBAL>
<COMMENT>Move fall value from WFN4 into a different global so the same "Fall_value" variable can be used in both mode. Note: WFN4</COMMENT>
<GLOBAL>WORK_FIELD_NUM_04</GLOBAL>
<COMMENT>in spring mode contains the fall units, but in fall mode contains the fall item type value</COMMENT>
</ASSIGN>
<ASSIGN>
<GLOBAL>COMBINED_UNIT_MAX_VALUE</GLOBAL>
<COMMENT>Max value based on per credit times combined units, or remaining Spring eligible value when in Fall mode</COMMENT>
<LOCAL>ORIGINAL_EFA_AY_VALUE</LOCAL>
<COMMENT>Original Merit AY amt</COMMENT>
<OPERATOR>-</OPERATOR>
<PAREN>
<GLOBAL>WORK_FIELD_NUM_01</GLOBAL>
<COMMENT>Fall Units</COMMENT>
<OPERATOR>*</OPERATOR>
<GLOBAL>PER_CREDIT</GLOBAL>
</PAREN>
</ASSIGN>
<ASSIGN>
<GLOBAL>GLOBAL_AMT</GLOBAL>
<VALUE>15</VALUE>
<COMMENT>Default Term Units</COMMENT>
<OPERATOR>*</OPERATOR>
<GLOBAL>PER_CREDIT</GLOBAL>
</ASSIGN>
</IF>
<COMMENT>End of separate Fall and Spring logic</COMMENT>
</EQUATION>
In the example above, the first "Assign" element is actually doing this: global variable "PER_CREDIT" = global variable "GLOBAL_AWARD" / 30
Would XMLReader be a better approach, or is this type of XML not really something that can be converted in the way I am trying to do?
Edit: I should have mentioned, I was going to try to do this via C# (like windows form, or console, with the eventual goal of outputting a flowchart somehow) though I am also thinking python might be a better choice given the visualization goal