styles/vym2txt.xsl
changeset 82 920e6ed5889b
parent 37 df767ed748f3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/styles/vym2txt.xsl	Sun Jan 30 12:59:10 2005 +0000
     1.3 @@ -0,0 +1,138 @@
     1.4 +<?xml version="1.0" encoding="UTF-8" ?>
     1.5 +
     1.6 +<!--
     1.7 +    Document   : vym2txt.xsl
     1.8 +    Created on : 20040317
     1.9 +	Modified   : 20040417
    1.10 +	Version    : 0.1
    1.11 +    Author     : Clemens Kraus (http://www.clemens-kraus.de)
    1.12 +    Description: transforms vym-files into text-format.
    1.13 +    
    1.14 +-->
    1.15 +
    1.16 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    1.17 +
    1.18 +  <xsl:output method="text" indent="no" encoding="UTF-8"/> 
    1.19 +  <xsl:param name="filenamep" />
    1.20 +  <xsl:variable name="filename" select="$filenamep"/>
    1.21 +  
    1.22 +  <xsl:variable name="fn" >
    1.23 +	<xsl:call-template name="getfn" >
    1.24 +		<xsl:with-param name="txt" select="$filename" />
    1.25 +	</xsl:call-template>
    1.26 +  </xsl:variable>
    1.27 +
    1.28 +  <xsl:variable name="path" >
    1.29 +	  <xsl:value-of select="normalize-space( substring($filename, 1, number(string-length($filename)-string-length($fn))) )" />
    1.30 +  </xsl:variable>
    1.31 +
    1.32 +
    1.33 +  <xsl:template match="/">
    1.34 +  
    1.35 +    <xsl:text>#VYM-Export VYM-Version:</xsl:text><xsl:value-of select="vymmap/@version"/>
    1.36 +    <xsl:text>&#xA;&#xA;</xsl:text>
    1.37 +	  
    1.38 +	
    1.39 +    <xsl:value-of select="vymmap/mapcenter/heading"/>
    1.40 +	<xsl:text>&#xA;&#xA;</xsl:text>
    1.41 +		
    1.42 +	
    1.43 +	<xsl:apply-templates select="vymmap/mapcenter/branch" >
    1.44 +		<xsl:with-param name="indent" select="''" />
    1.45 +	</xsl:apply-templates>
    1.46 +
    1.47 +  </xsl:template>
    1.48 +
    1.49 +	
    1.50 +  
    1.51 +  
    1.52 +  <xsl:template match="branch">
    1.53 +    <xsl:param name="width" select="70" />
    1.54 +	
    1.55 +	
    1.56 +	<xsl:call-template name="gen-anchor-tag" >
    1.57 +		<xsl:with-param name="indent" select="$indent" />
    1.58 +	</xsl:call-template>
    1.59 +	  
    1.60 +	
    1.61 +	<xsl:apply-templates select="branch" >
    1.62 +		<xsl:with-param name="indent" select="concat($indent, ' ')" />
    1.63 +	</xsl:apply-templates>
    1.64 +
    1.65 +  </xsl:template>
    1.66 +
    1.67 +
    1.68 +  
    1.69 +  
    1.70 +  <xsl:template name="gen-anchor-tag">
    1.71 +    <xsl:param name="indent"/>
    1.72 +
    1.73 +	<xsl:value-of select="$indent"/><xsl:text>- </xsl:text><xsl:value-of select="heading"/>
    1.74 +
    1.75 +	
    1.76 +    <xsl:if test="@url != ''"> (<xsl:value-of select="@url"/>)</xsl:if>
    1.77 +	
    1.78 +	
    1.79 +	<xsl:apply-templates select="note/@href" >
    1.80 +		<xsl:with-param name="indent" select="$indent" />
    1.81 +	</xsl:apply-templates>
    1.82 +
    1.83 +    <xsl:text>&#xA;</xsl:text>
    1.84 +  </xsl:template>
    1.85 +
    1.86 +
    1.87 +  
    1.88 +  
    1.89 +  
    1.90 +  <xsl:template match="note/@href">
    1.91 +    <xsl:param name="indent"/>
    1.92 +    
    1.93 +    <xsl:variable name="actualnotename">
    1.94 +      <xsl:value-of select="substring-after(current(),':')"/>
    1.95 +    </xsl:variable>
    1.96 +
    1.97 +    <xsl:variable name="note-name">
    1.98 +	    <xsl:if test="$path = ''">
    1.99 +			<xsl:value-of select="$actualnotename"/>
   1.100 +		</xsl:if>
   1.101 +	    <xsl:if test="not($path = '')">
   1.102 +			<xsl:value-of select="concat($path, '/', $actualnotename)"/>
   1.103 +		</xsl:if>
   1.104 +	</xsl:variable>
   1.105 +	
   1.106 +	
   1.107 +	<xsl:variable name="currentID" select="@id" />
   1.108 +	
   1.109 +    <xsl:text>&#xA;</xsl:text>
   1.110 +  
   1.111 +	<xsl:for-each select="document($note-name)/note/line">
   1.112 +		<xsl:value-of select="$indent"/><xsl:text>  </xsl:text><xsl:value-of select="."/>
   1.113 +	</xsl:for-each>
   1.114 +		
   1.115 +  </xsl:template>
   1.116 +
   1.117 +  
   1.118 +  
   1.119 +  
   1.120 +  
   1.121 +  <xsl:template name="getfn">
   1.122 +	  <xsl:param name="txt" select="." />
   1.123 +	  
   1.124 +	  <xsl:choose>
   1.125 +		  <xsl:when test="contains($txt, '/')" >
   1.126 +		  	<xsl:variable name="right" select="substring-after($txt, '/')" />
   1.127 +			<xsl:if test="string-length($right)>1" >
   1.128 +			  <xsl:call-template name="getfn" >
   1.129 +				  <xsl:with-param name="txt" select="$right" />
   1.130 +			  </xsl:call-template>
   1.131 +			</xsl:if>
   1.132 +		  </xsl:when>
   1.133 +		  <xsl:otherwise>
   1.134 +			  <xsl:value-of select="$txt" />
   1.135 +		  </xsl:otherwise>
   1.136 +	  </xsl:choose>
   1.137 +	  
   1.138 +  </xsl:template>
   1.139 +  
   1.140 +</xsl:stylesheet>
   1.141 +