šablona/makra/odkazy.xsl
author František Kučera <franta-hg@frantovo.cz>
Sat, 07 Jan 2012 01:57:27 +0100
changeset 57 768a7eecb0cf
parent 56 24e50902b58e
child 61 9503eb8377f1
permissions -rw-r--r--
odkaz #16 na RFCčko musí být číselný

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	exclude-result-prefixes="m">

	<!--
		Interní odkazy
		**************
		Slouží k vkládání odkazů na jiné stránky v rámci webu.
		*
		@href zadáváme jen název souboru bez přípony – s nezakódovanou češtinou a s mezerami
		@typ nevyplňujeme
	-->
	<xsl:template match="m:a[not(@typ)]">
		<a>
			<xsl:copy-of select="@*"/>
			<xsl:attribute name="href">
				<xsl:value-of select="encode-for-uri(concat(@href, $výstupníPřípona))"/>
			</xsl:attribute>
			<xsl:apply-templates/>
		</a>
	</xsl:template>

	<!--
		Trac – wiki
		***********
		Odkazy na Trac našeho generátoru.
		*
		@href nečíselné parametry vedou do wiki
	-->
	<xsl:template match="m:a[@typ='trac' and not(number(@href))]">
		<xsl:call-template name="vložOdkaz">
			<xsl:with-param name="url" select="
				concat(
					'https://trac.frantovo.cz/xml-web-generator/wiki/', 
					replace(encode-for-uri(@href), '%2F', '/')
				)"/>
		</xsl:call-template>		
	</xsl:template>
	
	<!--
		Trac – úkoly
		************
		Odkazy na Trac našeho generátoru.
		*
		@href číselné parametry vedou na úkoly
	-->
	<xsl:template match="m:a[@typ='trac' and number(@href)]">
		<xsl:call-template name="vložOdkaz">
			<xsl:with-param name="url" select="
				concat(
					'https://trac.frantovo.cz/xml-web-generator/ticket/', 
					@href
				)"/>
		</xsl:call-template>
	</xsl:template>

	<!--
		Wikipedia
		*********
		Stránka v encyklopedii
		*
		@href název stránky
		@jazyk kód jazyka (výchozí je čeština)
	-->
	<xsl:template match="m:a[@typ='wiki']">
		<xsl:call-template name="vložOdkaz">
			<xsl:with-param name="url" select="
				concat(
					'https://secure.wikimedia.org/wikipedia/', (@jazyk,'cs')[1], '/wiki/', 
					encode-for-uri(@href)
				)"/>
		</xsl:call-template>
	</xsl:template>
	
	<!-- 
		Seznam.cz
		*********
		Vyhledávání pomocí Seznamu
		*
		@href náš dotaz
	-->
	<xsl:template match="m:a[@typ='seznam']">
		<xsl:call-template name="vložOdkaz">
			<xsl:with-param name="url" select="
				concat(
					'http://search.seznam.cz/?q=', 
					encode-for-uri(@href)
				)"/>
		</xsl:call-template>
	</xsl:template>

	<!-- 
		Google.com
		**********
		Vyhledávání pomocí Googlu
		*
		@href náš dotaz
	-->
	<xsl:template match="m:a[@typ='google']">
		<xsl:call-template name="vložOdkaz">
			<xsl:with-param name="url" select="
				concat(
					'https://encrypted.google.com/search?q=', 
					encode-for-uri(@href)
				)"/>
		</xsl:call-template>	
	</xsl:template>
	
	<!-- 
		Request for comments
		********************
		Internetové standardy – RFC
		*
		@href číslo RFCčka
	-->
	<xsl:template match="m:a[@typ='rfc' and number(@href)]">
		<xsl:call-template name="vložOdkaz">
			<xsl:with-param name="url" select="
				concat(
					'https://tools.ietf.org/html/rfc',
					@href
				)"/>
		</xsl:call-template>
	</xsl:template>
	
	
	<xsl:template name="vložOdkaz">
		<xsl:param name="url"/>
		<a>
			<xsl:copy-of select="@*"/>
			<xsl:attribute name="href"><xsl:value-of select="$url"/></xsl:attribute>
			<xsl:apply-templates/>
		</a>
	</xsl:template>

</xsl:stylesheet>