šablona/makra/tabulka.xsl
changeset 56 24e50902b58e
child 61 9503eb8377f1
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/šablona/makra/tabulka.xsl	Sat Jan 07 01:44:01 2012 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<xsl:stylesheet version="2.0"
     1.6 +	xmlns="http://www.w3.org/1999/xhtml"
     1.7 +	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
     1.8 +	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     1.9 +	exclude-result-prefixes="m">
    1.10 +	    
    1.11 +	<!--
    1.12 +		Jednoduché tabulky
    1.13 +		******************
    1.14 +		Data zadáváme do těla elementu.
    1.15 +		Sloupce oddělujeme tabulátorem (může jich být víc, minimálně však jeden, mezery nestačí).
    1.16 +		První řádek se považuje za záhlaví (nadpisy sloupců).
    1.17 +		*
    1.18 +	-->
    1.19 +    <xsl:template match="m:tabulka">
    1.20 +    	<table>
    1.21 +    		<xsl:variable name="data" select="replace(replace(text(), '^\s+', ''),'\s+$','')"/>
    1.22 +    		<xsl:variable name="hlavička" select="substring-before($data, '&#10;')"/>
    1.23 +    		<xsl:variable name="tělo" select="substring-after($data, '&#10;')"/>
    1.24 +    		<thead>
    1.25 +    			<tr>
    1.26 +    				<xsl:for-each select="tokenize($hlavička, '\t+')">
    1.27 +    					<xsl:if test="normalize-space(.)">
    1.28 +							<td><xsl:value-of select="normalize-space(.)"/></td>
    1.29 +						</xsl:if>
    1.30 +					</xsl:for-each>
    1.31 +    			</tr>
    1.32 +    		</thead>
    1.33 +    		<tbody>
    1.34 +				<xsl:for-each select="tokenize($tělo, '\n')">
    1.35 +					<xsl:if test="normalize-space(.)">
    1.36 +						<tr>
    1.37 +							<xsl:for-each select="tokenize(., '\t+')">
    1.38 +								<xsl:if test="normalize-space(.)">
    1.39 +									<td><xsl:value-of select="normalize-space(.)"/></td>
    1.40 +								</xsl:if>
    1.41 +							</xsl:for-each>
    1.42 +						</tr>
    1.43 +					</xsl:if>
    1.44 +				</xsl:for-each>
    1.45 +    		</tbody>
    1.46 +    	</table>    
    1.47 +    </xsl:template>
    1.48 +
    1.49 +</xsl:stylesheet>
    1.50 +