šablona/makra/tabulka.xsl
author František Kučera <franta-hg@frantovo.cz>
Sat Jan 07 01:57:27 2012 +0100 (2012-01-07)
changeset 57 768a7eecb0cf
child 61 9503eb8377f1
permissions -rw-r--r--
odkaz #16 na RFCčko musí být číselný
franta-hg@51
     1
<?xml version="1.0" encoding="UTF-8"?>
franta-hg@51
     2
<xsl:stylesheet version="2.0"
franta-hg@51
     3
	xmlns="http://www.w3.org/1999/xhtml"
franta-hg@51
     4
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
franta-hg@51
     5
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
franta-hg@51
     6
	exclude-result-prefixes="m">
franta-hg@51
     7
	    
franta-hg@51
     8
	<!--
franta-hg@51
     9
		Jednoduché tabulky
franta-hg@51
    10
		******************
franta-hg@51
    11
		Data zadáváme do těla elementu.
franta-hg@51
    12
		Sloupce oddělujeme tabulátorem (může jich být víc, minimálně však jeden, mezery nestačí).
franta-hg@51
    13
		První řádek se považuje za záhlaví (nadpisy sloupců).
franta-hg@51
    14
		*
franta-hg@51
    15
	-->
franta-hg@51
    16
    <xsl:template match="m:tabulka">
franta-hg@51
    17
    	<table>
franta-hg@51
    18
    		<xsl:variable name="data" select="replace(replace(text(), '^\s+', ''),'\s+$','')"/>
franta-hg@51
    19
    		<xsl:variable name="hlavička" select="substring-before($data, '&#10;')"/>
franta-hg@51
    20
    		<xsl:variable name="tělo" select="substring-after($data, '&#10;')"/>
franta-hg@51
    21
    		<thead>
franta-hg@51
    22
    			<tr>
franta-hg@51
    23
    				<xsl:for-each select="tokenize($hlavička, '\t+')">
franta-hg@51
    24
    					<xsl:if test="normalize-space(.)">
franta-hg@51
    25
							<td><xsl:value-of select="normalize-space(.)"/></td>
franta-hg@51
    26
						</xsl:if>
franta-hg@51
    27
					</xsl:for-each>
franta-hg@51
    28
    			</tr>
franta-hg@51
    29
    		</thead>
franta-hg@51
    30
    		<tbody>
franta-hg@51
    31
				<xsl:for-each select="tokenize($tělo, '\n')">
franta-hg@51
    32
					<xsl:if test="normalize-space(.)">
franta-hg@51
    33
						<tr>
franta-hg@51
    34
							<xsl:for-each select="tokenize(., '\t+')">
franta-hg@51
    35
								<xsl:if test="normalize-space(.)">
franta-hg@51
    36
									<td><xsl:value-of select="normalize-space(.)"/></td>
franta-hg@51
    37
								</xsl:if>
franta-hg@51
    38
							</xsl:for-each>
franta-hg@51
    39
						</tr>
franta-hg@51
    40
					</xsl:if>
franta-hg@51
    41
				</xsl:for-each>
franta-hg@51
    42
    		</tbody>
franta-hg@51
    43
    	</table>    
franta-hg@51
    44
    </xsl:template>
franta-hg@51
    45
franta-hg@51
    46
</xsl:stylesheet>
franta-hg@51
    47