šablona/makra/odkazy.xsl
changeset 53 7403128a8e0a
parent 51 df1f942f7b69
child 54 15c66c9048f2
equal deleted inserted replaced
52:a221785fe3ac 53:7403128a8e0a
     2 <xsl:stylesheet version="2.0"
     2 <xsl:stylesheet version="2.0"
     3 	xmlns="http://www.w3.org/1999/xhtml"
     3 	xmlns="http://www.w3.org/1999/xhtml"
     4 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
     4 	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
     5 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     5 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     6 	exclude-result-prefixes="m">
     6 	exclude-result-prefixes="m">
     7    
     7 
     8     <!--
     8 	<!--
     9     	Makro pro převod interních odkazů:
     9 		Odkazy
    10     		- doplnění správné přípony
    10 		******
    11     		- URL kódování znaků
    11 		Slouží hlavně k vkládání odkazů na jiné stránky v rámci webu.
    12     -->
    12 		*
    13     <xsl:template match="m:a">
    13 		@href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami
    14     	<a>
    14 		@typ jiné typy odkazů (výchozí jsou interní odkazy v rámci webu)
    15     		<xsl:copy-of select="@*"/>
    15 	-->
    16     		<xsl:attribute name="href">
    16 	<xsl:template match="m:a">
    17     			<xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
    17 		<a>
    18     		</xsl:attribute>
    18 			<xsl:copy-of select="@*"/>
    19     		<xsl:apply-templates/>
    19 			<xsl:attribute name="href">
    20     	</a>
    20 				<xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
    21     </xsl:template>
    21 			</xsl:attribute>
    22     
    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 
    23 </xsl:stylesheet>
   101 </xsl:stylesheet>