views:

95

answers:

1

I have the following input:

<node TEXT="txt">
  <node TEXT="txt">
    <node TEXT="txt"/>
    <node TEXT="txt"/>
  </node>
  <node TEXT="txt"/>
</node>
<node TEXT="txt"/>

I am currently using:

<xsl:number level="multiple" count="node" format="1"/>

within an XSTL script to receive the following output:

1 txt
1.1 txt
1.1.1 txt
1.1.2 txt
1.2 txt
2 txt

but i want to have this output:

* txt
** txt
*** txt
*** txt
** txt
* txt

Can you help me?

PS: I want to convert a freemind map to basic mediawiki list syntax. And yes! i am aware that there are several ways to get native freemind maps into media wikis, but i need the conversion of the <node>-tree to ***-lists

+2  A: 

One simple way to do this is to just translate the result of the

<xsl:number/>
into the wanted format.

This transformation:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

<xsl:output method="text"/>

<xsl:strip-space elements="*"/>

<xsl:template match="node">
  <xsl:variable name="vIndent">
    <xsl:number level="multiple" count="node"/>
  </xsl:variable>

  <xsl:value-of select=
   "concat(translate($vIndent,
                     '1234567890.',
                     '**********'),
           ' ',
           @TEXT,
         '&#xA;'
         )"/>
 <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

when applied on this XML document:

<t>
    <node TEXT="txt">
     <node TEXT="txt">
      <node TEXT="txt"/>
      <node TEXT="txt"/></node>
     <node TEXT="txt"/></node>
    <node TEXT="txt"/>
</t>

produces the wanted result:

* txt
** txt
*** txt
*** txt
** txt
* txt

Note the use of the translate() function to discard any "." characters and to translate any digit into an "*".

Dimitre Novatchev
thank you, this worked quite well
Juve