šablona/stránka.xsl
author František Kučera <franta-hg@frantovo.cz>
Sun Apr 03 17:44:58 2011 +0200 (2011-04-03)
changeset 8 ad0ee12d13fd
parent 6 801a8935caf7
child 10 4e70453a027f
permissions -rw-r--r--
RSS agregace, #2
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <xsl:stylesheet version="2.0"
     3 	xmlns="http://www.w3.org/1999/xhtml"
     4 	xmlns:h="http://www.w3.org/1999/xhtml"
     5 	xmlns:g="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/prostor"
     6 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     7 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
     8 	xmlns:svg="http://www.w3.org/2000/svg"
     9 	exclude-result-prefixes="fn h g">
    10 	<xsl:output 
    11 		method="xml" 
    12 		indent="yes" 
    13 		encoding="UTF-8"		
    14 		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
    15 		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
    16 	
    17 	<!-- Celý dokument: -->
    18 	<xsl:template match="/">
    19 		<html>
    20 			<head>
    21 				<title><xsl:value-of select="g:stránka/g:nadpis"/></title>
    22 				<link title="Novinky (Atom)" href="atom.xml" type="application/atom+xml" rel="alternate"/>
    23 				<link title="Novinky (RSS)"  href="rss.xml"  type="application/rss+xml"  rel="alternate"/>				
    24 			</head>
    25 			<body>
    26 				<xsl:apply-templates select="document(fn:encode-for-uri('../vstup/záhlaví.inc'))/g:stránka/h:text/node()"/>			
    27 				<h1><xsl:value-of select="g:stránka/g:nadpis"/></h1>
    28 				<xsl:apply-templates select="g:stránka/h:text/node()"/>
    29 				<ul id="nabídka">
    30 					<xsl:for-each select="collection('../vstup/?select=*.xml')[g:stránka/g:pořadí]">
    31 						<xsl:sort select="empty(./g:stránka/g:pořadí)"/>
    32 						<xsl:sort select="./g:stránka/g:pořadí"/>
    33 						<li>
    34 							<xsl:variable name="xmlSoubor" select="tokenize(document-uri(.), '/')[last()]"/>
    35 							<xsl:variable name="xhtmlSoubor" select="replace($xmlSoubor, '.xml', '.xhtml')"/>
    36 							<a href="{fn:encode-for-uri($xhtmlSoubor)}"><xsl:value-of select="./g:stránka/g:nadpis"/></a>
    37 						</li>
    38 					</xsl:for-each>
    39 				</ul>
    40 				<xsl:apply-templates select="document(fn:encode-for-uri('../vstup/zápatí.inc'))/g:stránka/h:text/node()"/>				
    41 			</body>
    42 		</html>
    43 	</xsl:template>
    44 	
    45 	<!-- Kopírujeme elementy, ale vynecháme nepoužité xmlns deklarace: -->
    46 	<xsl:template match="*">
    47 		<xsl:element name="{name()}">
    48 			<xsl:copy-of select="@*"/>
    49 			<xsl:apply-templates/>
    50 		</xsl:element>
    51     </xsl:template>
    52 
    53 </xsl:stylesheet>