Need Script to Assign Children Node Text to Parent Node's Attribute Values

  • Z

    Z - 2014-03-24


    Is there a script that assigns the text of a parents node's children to the parent node's attribute values, child by child, in order?

    If so, where can I get it?

    If not, is it possible for such a script to exist?

    If yes, if someone has the time to write this script, I would be willing to compensate the person.

    Also, if yes and no one has the time to write the script, if someone could just point me in the write direction . . . e.g., write the header of the script file, I might be able to write the script myself: I took an intermediate class in programming in C and C++ about 15 years ago and could probably study some Groovy help files to cobble something together.

    1. Would it be best to use getChildren() or instead to use getText() in a loop?
    2. Is there an "assignAttributeValues( )" function in Groovy, and if so, what is its real name and can it take the java.util.List output that getChildren() returns?
    3. Better yet, is there an "assignJava.util.List()" function in Groovy? If so, what is its real name and does it work with attributes and attribute values?

    What exactly is a java.util.List?

    Thank you SO very much for any assistance: I am using Freemind in Docear to analyze a lot of data, and having such a script would be . . . life changing. Literally: It would change how my life will be lived over the next few weeks. :)

    Take care, and godspeed with your own endeavors.


  • Z

    Z - 2014-03-24

    Well, I am responding to my own question with a script I managed to write today, this being my second day to have even heard of Groovy. (So, proceed with it with caution -- smile!) In fact, this is the first script I've ever written.

    It works pretty well so far with the current version of FreeMind. It does not work within Docear because Docear is using an older version of FreeMind that does't support some of the functions used. However, you can export back-and-forth between FreeMind and Docear (with the current versions of both programs) if that would be an issue for you. (I need to use this script for Docear-generated data, for example.)

    One issue with the script: If attribute names are not unique, you'll get SOME mixup.

    Also . . . it ASSUMES that the script is the FIRST attribute of the node being processed, and so it skips over processing it. I will likely modify this once I figure out how to run this script from outside of a node.

    Those are the main issues. The code is included below.

    Any improvements, alternatives, etc. would be GREATLY appreciated. Or, if this script already exists natively, so to speak, in FreeMind or Groovy, advisement of that fact and how to obtain the script would be appreciated as well! ;)


    import freemind.modes.;
    import freemind.modes.attributes.
    import freemind.view.mindmapview.attributeview.;
    import freemind.view.mindmapview.
    import javax.swing.JOptionPane;

    if(!node.hasChildren()) {

    if(!node.getAttributes().getRowCount()) {

    def it = node.childrenUnfolded();
    def child =;
    def desiredstring = child.getText();

    row = 1;

    for (row in 1..<node.getAttributes().getRowCount()) {
    def selectedattribute = node.getAttributes().getName(row);
    c.editAttribute(node, selectedattribute, desiredstring);

    if (!it.hasNext()) {
    else {
    row = row+1;
    child =;
    desiredstring = child.getText();

  • Z

    Z - 2014-03-24

    Uh oh!

    I just realized something: Some of the text of the script got interpreted as markup language due to the way this forum works. This means the script above is missing some asterisks in key places.

    Here is what you'd need to add to the script text above:

    For lines 1-4 of the above script, add an asterisk before each semi-colon (toward the end of each line). The 5th line will LACK AN ASTERISK.

    I think that covers it!

    Take care!

  • Christian Foltin


    assing the script to a style, then it is independant of the node.
    Script looks ok.

    Br, Chris

    Last edit: Christian Foltin 2014-03-25
  • Z

    Z - 2014-03-25

    Hi, Chris.

    How do I assign the script to a style?

    Thank you!



Log in to post a comment.