styles/vym2kdebookmarks.xsl
author insilmaril
Wed, 27 Feb 2008 16:09:06 +0000
changeset 671 367d875453ed
parent 12 58e7594239df
permissions -rw-r--r--
autosave fix
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!DOCTYPE xsl:stylesheet
     3 [
     4    <!-- Namespace for XHTML -->
     5    <!ENTITY xhtmlns "http://www.w3.org/1999/xhtml">
     6 ]>
     7 
     8 <!--
     9     Author      : Uwe Drechsel  <vym@InSilmaril.de>
    10 	Credits to  : Thomas Schraitle for his patience in explaining XSL to me
    11     Description : transforms vym maps into KDE Bookmarks
    12 -->
    13 
    14 <xsl:stylesheet version="1.0"
    15     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    16     xmlns:date="http://exslt.org/dates-and-times"
    17     extension-element-prefixes="date">
    18 
    19 
    20 <xsl:output method="xml"
    21     doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    22     doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    23     encoding="UTF-8"
    24     indent="yes"
    25     media-type="application/xhtml+xml"/>
    26 
    27 <!-- ======================================= -->
    28 
    29 <xsl:template match="/">
    30   <xsl:apply-templates/>
    31 </xsl:template>
    32 
    33 
    34 <xsl:template match="text()"/>
    35 
    36 
    37 <xsl:template match="vymmap">
    38   <xbel>
    39     <xsl:apply-templates/>
    40   </xbel>
    41 </xsl:template>
    42 
    43 
    44 <xsl:template match="mapcenter">
    45 
    46   <xsl:apply-templates/>
    47 </xsl:template>
    48 
    49 
    50 <xsl:template match="branch">
    51    <xsl:choose>
    52      <xsl:when test="heading='KDE'">
    53         <xsl:apply-templates select="branch" mode="kde"/>
    54      </xsl:when>
    55      <xsl:when test=". = 'Firefox'">
    56         <xsl:apply-templates mode="firefox"/>
    57      </xsl:when>
    58      <!-- ... -->
    59      <xsl:otherwise>
    60        <xsl:apply-templates/>
    61      </xsl:otherwise>
    62    </xsl:choose>
    63 
    64   <xsl:apply-templates/>
    65 </xsl:template>
    66 
    67 <xsl:template match="heading" mode="kde">
    68       <title>		
    69       <xsl:value-of select="normalize-space (.)"/>
    70 	  </title>
    71 
    72    <xsl:choose>
    73      <xsl:when test=". = 'KDE'">
    74         <xsl:apply-templates mode="kde"/>
    75      </xsl:when>
    76      <xsl:otherwise>
    77        <xsl:apply-templates/>
    78      </xsl:otherwise>
    79    </xsl:choose>
    80 
    81   <xsl:apply-templates/>
    82 </xsl:template>
    83 
    84 
    85 <xsl:template match="branch" mode="kde">
    86 	<xsl:choose>
    87 		<xsl:when test="@url">
    88 			<xsl:element name="bookmark">	
    89 				<xsl:attribute name="href" ><xsl:value-of select="@url" />
    90 				</xsl:attribute>
    91 				<xsl:apply-templates mode="kde"/>
    92 			</xsl:element>
    93 		</xsl:when>
    94 		<xsl:otherwise>
    95 			<xsl:choose>
    96 				<xsl:when test="contains(heading,'***')">
    97 					<separator folded="yes" />
    98 				</xsl:when>
    99 				<xsl:otherwise>
   100 					<folder folded="yes" icon="bookmark_folder">
   101 						<xsl:apply-templates mode="kde"/>
   102 					</folder>
   103 				</xsl:otherwise>
   104 			</xsl:choose>	
   105 
   106 	</xsl:otherwise>
   107 	</xsl:choose>
   108 </xsl:template>
   109 
   110 <!--
   111 		  <xsl:text>&#10;</xsl:text>
   112 
   113 				<xsl:message> WARNING: No @url attribute given of "<xsl:value-of select="normalize-space(heading)"/>"</xsl:message>
   114 
   115 <xsl:template match="branch">
   116   <xsl:choose>
   117     <xsl:when test="@url">
   118       <xsl:text> *nokde* </xsl:text>
   119       <xsl:value-of select="@url"/>
   120       <xsl:text>&#10;</xsl:text>
   121     </xsl:when>
   122     <xsl:otherwise>
   123       <xsl:message> WARNING: No @url attribute given of "<xsl:value-of select="normalize-space(heading)"/>"</xsl:message>
   124     </xsl:otherwise>
   125   </xsl:choose>
   126 
   127   <xsl:apply-templates/>
   128 
   129 </xsl:template>
   130 -->
   131 
   132 
   133 </xsl:stylesheet>