I am trying to modify a proprietory XML file using XSL and MSXSL. The software in question is Blumind (blumind.org) a very pretty and fully portable mind mapping application (I have no connection with the author). It offer “progress bars” and I would like the progress at each node to reflect the sum of the progress below. It is my intention to use this as a combined project modelling and management tool.
I plan to run a batch file calling MSXML.EXE each time I load one of these file to update the progress. It is important that the structure of the file remains unchanged, only altering the value at various /map/nodes/node/widgets/widget/@value points and then corresponding /map/nodes/node/widgets/widget/@max points.
Not all nodes will have a progress bar, not all nodes with progress bars will have children with progress bars. So the logic needs to only change the progress bar to the sum of progress in the children – if the children have progress bars! Where the @value for “progress” is changed we need to make a similar change in the @max value to keep the denominator in sync with the “progress” (the widget will display the correct proportions, but will not calculate the percent – it justs adds “%” to the value!).
Sorry if this is difficult to visualise, I would recommend downloading version 1.3 portable zip file from http://blumind.org/download and loading this file (rename test.bmd) :-
Sorry I have tried so amany ways to ident this code – how should I do it?
<?xml version="1.0" encoding="utf-8"?>
<map name="test" document_type="Blumind" editor_version="1.3.21.1">
<!--Create by Blumind, you can download it free from http://www.blumind.org/download-->
<info>
<author>
</author>
<company>
</company>
<version>1.0</version>
</info>
<layout>TREE_RIGHT</layout>
<attributes>
<item name="editor_show_sidebar">True</item>
</attributes>
<style>
<back_color>White</back_color>
<fore_color>Black</fore_color>
<line_color>LightSlateGray</line_color>
<border_color>SlateGray</border_color>
<node_back_color>LightGray</node_back_color>
<node_fore_color>Black</node_fore_color>
<select_color>RoyalBlue</select_color>
<hover_color>MediumSlateBlue</hover_color>
<link_line_color>Green</link_line_color>
</style>
<nodes>
<node text="Overall Progress">
<style>
<back_color>Silver</back_color>
<fore_color>Black</fore_color>
<border_color>Black</border_color>
<padding>12</padding>
</style>
<widgets>
<widget type="PROGRESSBAR" max="1000" min="0" value="500" show_text="False"
color="Green" back_color="White" fore_color="Black" height="39" align="Bottom" hyperlink="" />
</widgets>
<nodes>
<node text="Source Code " width="200">
<widgets>
<widget type="PROGRESSBAR" max="10" min="0" value="20" show_text="False"
color="Green" back_color="White" fore_color="Black" align="Bottom" hyperlink="" />
</widgets>
<nodes>
<node text="Primary Module" width="100">
<widgets>
<widget type="PROGRESSBAR" max="100" min="0" value="50" show_text="False"
color="Green" back_color="White" fore_color="Black" align="Bottom" hyperlink="" />
</widgets>
</node>
<node text="Legacy Import" width="100">
<widgets>
<widget type="PROGRESSBAR" max="100" min="0" value="50" show_text="False"
color="Green" back_color="White" fore_color="Black" align="Bottom" hyperlink="" />
</widgets>
</node>
</nodes>
</node>
<node text="Unit Testing" width="200">
<widgets>
<widget type="PROGRESSBAR" max="100" min="0" value="50" show_text="False"
color="Green" back_color="White" fore_color="Black" align="Bottom" hyperlink="" />
</widgets>
</node>
<node text="Acceptance Testing" width="200">
<widgets>
<widget type="PROGRESSBAR" max="100" min="0" value="20" show_text="False"
color="Green" back_color="White" fore_color="Black" align="Bottom" hyperlink="" />
</widgets>
</node>
<node text="Usability Testing" width="200">
<widgets>
<widget type="PROGRESSBAR" max="100" min="0" value="5" show_text="False"
color="Green" back_color="White" fore_color="Black" align="Bottom" hyperlink="" />
</widgets>
</node>
</nodes>
</node>
</nodes>
</map>
I am very new to XSL and am struggling, would I be better in AWK? The identity script looks useful to preserve the file structure. However I am at a lost trying to write the logic to change the values for progress. Instinct tells me if the file was parsed backwards it would be much easier!
Backwards:
1. For each new branch terminal – if a progress bar is detected keep a running total for @value and @max.
2. Assign this running total to any further progress bars until two branches converge.
3. At the convergence add the two sets of totals and continue.
As each node can have more than one progress bar it would be nice to repeat the calculations separately for each separate colour of progress bar found – a challenge to the XSL wizards out there!
I would be very grateful for any help.
This should do what I describe in my comment to your question:
I am assuming that
widgetelement do not have children and that they can have only the attributes that are listed in your example.