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