styles/mmap2vym.xsl
author insilmaril
Thu, 23 Feb 2006 16:39:16 +0000
changeset 219 a860efcaac4c
parent 218 160459d924a1
child 221 733c1fd16b73
permissions -rw-r--r--
Cleaned up mmap import a bit. Started to convert flags there, too
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 
     3 <!--
     4 	Document   : mmap2vym.xsl
     5 	Author     : Clemens Kraus (http://www.clemens-kraus.de)
     6 			     Uwe Drechsel <vym@InSilmaril.de>
     7 	
     8 	Description: transforms exported MindManager-files (version x5/6) into vym-format.
     9 	Bugs       : First Version, work still in progress!
    10 	Todo       : - xlinks still to be implemented
    11 	             - codes/symbols still to be implemented
    12 				 - Multimap links (.mmap) still to be implemented
    13 -->
    14 
    15 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    16 	xmlns:xlink="http://www.w3.org/1999/xlink"
    17 	xmlns:ap="http://schemas.mindjet.com/MindManager/Application/2003"
    18 	xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl math func"
    19 	xmlns:math="http://exslt.org/math"
    20 	xmlns:func="http://exslt.org/functions"
    21 	version="1.0">
    22 
    23 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    24 <xsl:param name="filenamep" />
    25 <xsl:variable name="filename" select="$filenamep"/>
    26 <!--<xsl:variable name="maxxCoord"><xsl:value-of select="math:max(map//xCoord)" /></xsl:variable>-->
    27 
    28 <!-- root element -->	
    29 <xsl:template match="/">
    30    	<xsl:element name="vymmap">
    31 		<!-- default settings: -->
    32 		<xsl:attribute name="comment">Generated with mmap2vym (V0.1.2) - MindManager to vym converter. More infos: www.clemens-kraus.de</xsl:attribute>
    33 
    34 		<xsl:variable name="author" select="concat(/ap:Map/ap:DocumentGroup/ap:Author/@UserName, ' ', /ap:Map/ap:DocumentGroup/ap:Author/@UserEmail)" />
    35 		<xsl:if test="$author">
    36 			<xsl:attribute name="author"><xsl:value-of select="$author"/></xsl:attribute>
    37 		</xsl:if>
    38 			
    39 		<xsl:element name="mapcenter">
    40 			<!-- recurse to map title node ... -->
    41 			<xsl:apply-templates select="ap:Map/ap:OneTopic/ap:Topic/ap:Text"/>
    42 			<xsl:apply-templates select="ap:Map/ap:OneTopic/ap:Topic/ap:SubTopics" />
    43 		</xsl:element>
    44 	</xsl:element>
    45 </xsl:template>
    46 
    47 <xsl:template match="ap:Topic/ap:Text">
    48 	<xsl:element name="heading">
    49 		<xsl:value-of select="@PlainText" />
    50 	</xsl:element>
    51 </xsl:template>
    52 
    53 
    54 <xsl:template match="ap:Topic">
    55 	<xsl:element name="branch">
    56 	<xsl:call-template name="position" />
    57 	<!-- =============================== hyperlink ================================ -->
    58 	<xsl:variable name="url" select="ap:Hyperlink" />
    59 	<xsl:if test="$url">
    60 	<xsl:attribute name="url"><xsl:value-of select="ap:Hyperlink/@Url"/></xsl:attribute>
    61 	</xsl:if>
    62 
    63 	<xsl:variable name="rect" select="ap:SubTopicShape/@SubTopicShape" />
    64 	<xsl:if test="contains($rect, 'Rectangle')">
    65 	<xsl:attribute name="frameType">Rectangle</xsl:attribute>
    66 	</xsl:if>
    67 	<xsl:apply-templates/>
    68 	</xsl:element>
    69 </xsl:template>
    70 
    71 
    72 <!-- =============================== position ================================ -->
    73 <xsl:template name="position">
    74 	<xsl:if test="ap:Offset/@CX!=''">
    75 		<xsl:attribute name="relPosX">
    76 			<xsl:value-of select="ap:Offset/@CX *3"/>
    77 		</xsl:attribute>
    78 	</xsl:if>		
    79 	<xsl:if test="ap:Offset/@CY!=''">
    80 		<xsl:attribute name="relPosY">
    81 			<xsl:value-of select="floor( ap:Offset/@CY *3 )"/>
    82 		</xsl:attribute>
    83 	</xsl:if>		
    84 </xsl:template>
    85 
    86 
    87 
    88 	
    89   <!-- ================================= getfn ================================== -->
    90   <!-- get the filename (without the path) -->
    91   
    92   <xsl:template name="getfn">
    93 	  <xsl:param name="txt" select="." />
    94 	  <xsl:choose>
    95 		  <xsl:when test="contains($txt, '/')" >
    96 		  	<xsl:variable name="right" select="substring-after($txt, '/')" />
    97 			<xsl:if test="string-length($right)>1" >
    98 			  <xsl:call-template name="getfn" >
    99 				  <xsl:with-param name="txt" select="$right" />
   100 			  </xsl:call-template>
   101 			</xsl:if>
   102 		  </xsl:when>
   103 		  <xsl:otherwise>
   104 			  <xsl:value-of select="$txt" />
   105 		  </xsl:otherwise>
   106 	  </xsl:choose>
   107 	  
   108   </xsl:template>
   109   
   110 <!-- =============================== Icons ================================ -->
   111 <xsl:template match="ap:Icon">
   112 	<xsl:element name="standardFlag">
   113 		<xsl:choose>
   114 			<xsl:when test="@IconType ='urn:mindjet:ExclamationMark'">exclamationmark</xsl:when>
   115 			<xsl:when test="@IconType ='urn:mindjet:SmileyHappy'">smiley-good</xsl:when>
   116 			<xsl:when test="@IconType ='urn:mindjet:SmileySad'">smiley-sad</xsl:when>
   117 		<xsl:otherwise>
   118 			<xsl:message>Unknown Flag found: <xsl:value-of select="@IconType"/></xsl:message>
   119 		</xsl:otherwise>
   120 		</xsl:choose>
   121 	</xsl:element>
   122 </xsl:template>
   123 	
   124   
   125   <!-- =============================== color ================================ -->
   126   <xsl:template match="color">
   127     <xsl:attribute name="textColor">
   128       <!-- switch from BBGGRR to #RRGGBB representation -->
   129       <xsl:text>#</xsl:text>
   130       <xsl:value-of select="substring( ., 5, 2 )"/>
   131       <xsl:value-of select="substring( ., 3, 2 )"/>
   132       <xsl:value-of select="substring( ., 1, 2 )"/>
   133     </xsl:attribute>
   134   </xsl:template>
   135 
   136   
   137 </xsl:stylesheet>
   138 
   139