Here is my attempt. I based it of your version, and added a few more features.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="/map">
        <xsl:text>var Map = {
</xsl:text>
        <xsl:apply-templates select="node">
            <xsl:with-param name="indent">
                <xsl:text>    </xsl:text>
            </xsl:with-param>
        </xsl:apply-templates>
        <xsl:text>
};
</xsl:text>
    </xsl:template>
    <xsl:template match="node">
        <xsl:param name="indent"/>
        <xsl:if test="position() != 1">
            <xsl:text>,
</xsl:text>
        </xsl:if>
        <xsl:value-of select="$indent"/>
        <xsl:text>"</xsl:text>
        <xsl:call-template name="escape-javascript">
            <xsl:with-param name="string"
                select="descendant-or-self::node/@TEXT"/>
        </xsl:call-template>
        <xsl:text>": </xsl:text>
        <xsl:choose>
            <xsl:when test="node">
                <xsl:text>{
</xsl:text>
                <xsl:apply-templates select="node">
                    <xsl:with-param name="indent">
                        <xsl:value-of select="$indent"/>
                        <xsl:text>    </xsl:text>
                    </xsl:with-param>
                </xsl:apply-templates>
                <xsl:text>
</xsl:text>
                <xsl:value-of select="$indent"/>
                <xsl:text>}</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>10</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <!--
        Javascript string escape template by Jeni Tennison
        Source: http://holytshirt.blogspot.com/2008/06/xslt-javascript-escaping.html
        Author page: http://www.jenitennison.com/
    -->
    <xsl:template name="escape-javascript">
        <xsl:param name="string" />
        <xsl:choose>
            <xsl:when test='contains($string, "'")'>
                <xsl:call-template name="escape-javascript">
                    <xsl:with-param name="string"
                        select='substring-before($string, "'")' />
                </xsl:call-template>
                <xsl:text>\'</xsl:text>
                <xsl:call-template name="escape-javascript">
                    <xsl:with-param name="string"
                        select='substring-after($string, "'")' />
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="contains($string, '
')">
                <xsl:call-template name="escape-javascript">
                    <xsl:with-param name="string"
                        select="substring-before($string, '
')" />
                </xsl:call-template>
                <xsl:text>\n</xsl:text>
                <xsl:call-template name="escape-javascript">
                    <xsl:with-param name="string"
                        select="substring-after($string, '
')" />
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="contains($string, '\')">
                <xsl:value-of select="substring-before($string, '\')" />
                <xsl:text>\\</xsl:text>
                <xsl:call-template name="escape-javascript">
                    <xsl:with-param name="string"
                        select="substring-after($string, '\')" />
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
If run on the Freemind test file, it produces the following output:
var Map = {
    "Notetest": {
        "Notetest": 10,
        "This is a node": {
            "with a linbreak \n subnode": 10,
            "and another subnode": 10,
            "and some folded subnodes": {
                "fold1": 10,
                "fold2": 10,
                "fold3": 10
            }
        },
        "Attributes": 10
    }
};