tags:

views:

224

answers:

1

Hi all, I am trying to get the best from the excellent open source Mind Map software FreeMind. As the result of designing a map I get a file which is in fact an XML file that has a simple structure:

<node TEXT="0th text i am interested in">
  <node TEXT="1st text i am interested in">
    <node TEXT="2nd text i am interested in">
      <node TEXT="3dh text i am interested in">
        <node TEXT="4th text i am interested in"/>
      </node>
    </node>
.........

For the sake of simplicity I have removed uninteresting (for my application) attributes.

As you can see, it is a simple containment hierarchy. There are code snippets used to export, but for my needs I would like to create a csv-like text where each node without children has to its left all its ancestor chain separated by comma, or colon, or whatever. I mean, I would like to see something like:

0th node; 1st text ; 2nd text; 3dh text; 4th text
... then a new data line

My goal is to be able to quickly check the full qualifying path to that node and this for each and only the terminal nodes. Should I able to get even a "dotted number" I'll be more than happy (I mean: 1.2.3.4... and so on, marking the nesting position of a node; I remember there is something useful in XSLT to do this).

This XSLT would allow to dump in csv a full qualified list in a snap after handling easily the hierarchy with the power of FreeMind interface

Unfortunately, I am unable to do that now, my XSLT fluency is very bad. It's a pity, XSLT are a very powerful tool... Does anyone have a hint for me?

+3  A: 

<xsl:output method="text" indent="no" encoding="utf-8" />
<xsl:strip-space elements="*" />

<xsl:template match="//node[not(node)]">
    <xsl:for-each select="ancestor::node">
        <xsl:value-of select="@TEXT" />
        <xsl:text> ; </xsl:text>
    </xsl:for-each>
    <xsl:value-of select="@TEXT" />
    <xsl:text>&#10;</xsl:text>
</xsl:template>

Jörn Horstmann
well... is perfect! x-actly what I was looking for... thanks!
Daniel