styles/vym2txt.xsl
author insilmaril
Wed, 01 Apr 2009 15:06:57 +0000
changeset 749 9ff332964015
parent 37 df767ed748f3
permissions -rw-r--r--
moved scroll functions from BranchObj to BranchItem
     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 
     3 <!--
     4     Document   : vym2txt.xsl
     5     Created on : 20040317
     6 	Modified   : 20040417
     7 	Version    : 0.1
     8     Author     : Clemens Kraus (http://www.clemens-kraus.de)
     9     Description: transforms vym-files into text-format.
    10     
    11 -->
    12 
    13 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    14 
    15   <xsl:output method="text" indent="no" encoding="UTF-8"/> 
    16   <xsl:param name="filenamep" />
    17   <xsl:variable name="filename" select="$filenamep"/>
    18   
    19   <xsl:variable name="fn" >
    20 	<xsl:call-template name="getfn" >
    21 		<xsl:with-param name="txt" select="$filename" />
    22 	</xsl:call-template>
    23   </xsl:variable>
    24 
    25   <xsl:variable name="path" >
    26 	  <xsl:value-of select="normalize-space( substring($filename, 1, number(string-length($filename)-string-length($fn))) )" />
    27   </xsl:variable>
    28 
    29 
    30   <xsl:template match="/">
    31   
    32     <xsl:text>#VYM-Export VYM-Version:</xsl:text><xsl:value-of select="vymmap/@version"/>
    33     <xsl:text>&#xA;&#xA;</xsl:text>
    34 	  
    35 	
    36     <xsl:value-of select="vymmap/mapcenter/heading"/>
    37 	<xsl:text>&#xA;&#xA;</xsl:text>
    38 		
    39 	
    40 	<xsl:apply-templates select="vymmap/mapcenter/branch" >
    41 		<xsl:with-param name="indent" select="''" />
    42 	</xsl:apply-templates>
    43 
    44   </xsl:template>
    45 
    46 	
    47   
    48   
    49   <xsl:template match="branch">
    50     <xsl:param name="width" select="70" />
    51 	
    52 	
    53 	<xsl:call-template name="gen-anchor-tag" >
    54 		<xsl:with-param name="indent" select="$indent" />
    55 	</xsl:call-template>
    56 	  
    57 	
    58 	<xsl:apply-templates select="branch" >
    59 		<xsl:with-param name="indent" select="concat($indent, ' ')" />
    60 	</xsl:apply-templates>
    61 
    62   </xsl:template>
    63 
    64 
    65   
    66   
    67   <xsl:template name="gen-anchor-tag">
    68     <xsl:param name="indent"/>
    69 
    70 	<xsl:value-of select="$indent"/><xsl:text>- </xsl:text><xsl:value-of select="heading"/>
    71 
    72 	
    73     <xsl:if test="@url != ''"> (<xsl:value-of select="@url"/>)</xsl:if>
    74 	
    75 	
    76 	<xsl:apply-templates select="note/@href" >
    77 		<xsl:with-param name="indent" select="$indent" />
    78 	</xsl:apply-templates>
    79 
    80     <xsl:text>&#xA;</xsl:text>
    81   </xsl:template>
    82 
    83 
    84   
    85   
    86   
    87   <xsl:template match="note/@href">
    88     <xsl:param name="indent"/>
    89     
    90     <xsl:variable name="actualnotename">
    91       <xsl:value-of select="substring-after(current(),':')"/>
    92     </xsl:variable>
    93 
    94     <xsl:variable name="note-name">
    95 	    <xsl:if test="$path = ''">
    96 			<xsl:value-of select="$actualnotename"/>
    97 		</xsl:if>
    98 	    <xsl:if test="not($path = '')">
    99 			<xsl:value-of select="concat($path, '/', $actualnotename)"/>
   100 		</xsl:if>
   101 	</xsl:variable>
   102 	
   103 	
   104 	<xsl:variable name="currentID" select="@id" />
   105 	
   106     <xsl:text>&#xA;</xsl:text>
   107   
   108 	<xsl:for-each select="document($note-name)/note/line">
   109 		<xsl:value-of select="$indent"/><xsl:text>  </xsl:text><xsl:value-of select="."/>
   110 	</xsl:for-each>
   111 		
   112   </xsl:template>
   113 
   114   
   115   
   116   
   117   
   118   <xsl:template name="getfn">
   119 	  <xsl:param name="txt" select="." />
   120 	  
   121 	  <xsl:choose>
   122 		  <xsl:when test="contains($txt, '/')" >
   123 		  	<xsl:variable name="right" select="substring-after($txt, '/')" />
   124 			<xsl:if test="string-length($right)>1" >
   125 			  <xsl:call-template name="getfn" >
   126 				  <xsl:with-param name="txt" select="$right" />
   127 			  </xsl:call-template>
   128 			</xsl:if>
   129 		  </xsl:when>
   130 		  <xsl:otherwise>
   131 			  <xsl:value-of select="$txt" />
   132 		  </xsl:otherwise>
   133 	  </xsl:choose>
   134 	  
   135   </xsl:template>
   136   
   137 </xsl:stylesheet>
   138