šablona/makra/odkazy.xsl
author František Kučera <franta-hg@frantovo.cz>
Sat, 07 Jan 2012 00:14:27 +0100
changeset 53 7403128a8e0a
parent 51 df1f942f7b69
child 54 15c66c9048f2
permissions -rw-r--r--
Makro pro odkazy #16 – Trac, Seznam, Google, RFC
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <xsl:stylesheet version="2.0"
     3 	xmlns="http://www.w3.org/1999/xhtml"
     4 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
     5 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     6 	exclude-result-prefixes="m">
     7 
     8 	<!--
     9 		Odkazy
    10 		******
    11 		Slouží hlavně k vkládání odkazů na jiné stránky v rámci webu.
    12 		*
    13 		@href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami
    14 		@typ jiné typy odkazů (výchozí jsou interní odkazy v rámci webu)
    15 	-->
    16 	<xsl:template match="m:a">
    17 		<a>
    18 			<xsl:copy-of select="@*"/>
    19 			<xsl:attribute name="href">
    20 				<xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
    21 			</xsl:attribute>
    22 			<xsl:apply-templates/>
    23 		</a>
    24 	</xsl:template>
    25 
    26 	<!--
    27 		Trac – wiki
    28 		***********
    29 		Odkazy na Trac našeho generátoru.
    30 		@href nečíselné parametry vedou do wiki
    31 	-->
    32 	<xsl:template match="m:a[@typ='trac' and not(number(@href))]">
    33 		<xsl:call-template name="vložOdkaz">
    34 			<xsl:with-param name="url" select="
    35 				concat(
    36 					'https://trac.frantovo.cz/xml-web-generator/wiki/', 
    37 					replace(encode-for-uri(@href), '%2F', '/')
    38 				)"/>
    39 		</xsl:call-template>		
    40 	</xsl:template>
    41 	
    42 	<!--
    43 		Trac – úkoly
    44 		************
    45 		Odkazy na Trac našeho generátoru.
    46 		@href číselné parametry vedou na úkoly
    47 	-->
    48 	<xsl:template match="m:a[@typ='trac' and number(@href)]">
    49 		<xsl:call-template name="vložOdkaz">
    50 			<xsl:with-param name="url" select="
    51 				concat(
    52 					'https://trac.frantovo.cz/xml-web-generator/ticket/', 
    53 					@href
    54 				)"/>
    55 		</xsl:call-template>
    56 	</xsl:template>
    57 
    58 	<!-- 
    59 		Seznam.cz
    60 		*********
    61 		Vyhledávání pomocí Seznamu
    62 	-->
    63 	<xsl:template match="m:a[@typ='seznam']">
    64 		<xsl:call-template name="vložOdkaz">
    65 			<xsl:with-param name="url" select="concat('http://search.seznam.cz/?q=', encode-for-uri(@href))"/>
    66 		</xsl:call-template>
    67 	</xsl:template>
    68 
    69 	<!-- 
    70 		Google.com
    71 		**********
    72 		Vyhledávání pomocí Googlu
    73 	-->
    74 	<xsl:template match="m:a[@typ='google']">
    75 		<xsl:call-template name="vložOdkaz">
    76 			<xsl:with-param name="url" select="concat('https://encrypted.google.com/search?q=', encode-for-uri(@href))"/>
    77 		</xsl:call-template>	
    78 	</xsl:template>
    79 	
    80 	<!-- 
    81 		Request for comments
    82 		********************
    83 		Internetové standardy – RFC
    84 	-->
    85 	<xsl:template match="m:a[@typ='rfc']">
    86 		<xsl:call-template name="vložOdkaz">
    87 			<xsl:with-param name="url" select="concat('https://tools.ietf.org/html/rfc', @href)"/>
    88 		</xsl:call-template>
    89 	</xsl:template>
    90 	
    91 	
    92 	<xsl:template name="vložOdkaz">
    93 		<xsl:param name="url"/>
    94 		<a>
    95 			<xsl:copy-of select="@*"/>
    96 			<xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
    97 			<xsl:apply-templates/>
    98 		</a>		
    99 	</xsl:template>
   100 
   101 </xsl:stylesheet>