šablona/stránka.xsl
changeset 46 c4ad66b1202e
parent 45 f52b3bb8cfcc
child 49 0be359e4c06f
--- a/šablona/stránka.xsl	Thu Jan 05 12:21:53 2012 +0100
+++ b/šablona/stránka.xsl	Thu Jan 05 14:49:04 2012 +0100
@@ -214,8 +214,36 @@
     	<xsl:variable name="prostýText" select="document(concat('http://lipsum.lipsum.com/feed/xml?amount=', @odstavců, '&amp;what=paragraphs'))/feed/lipsum"/>
     	<xsl:for-each select="fn:tokenize($prostýText, '\n')">
     		<p><xsl:value-of select="."/></p>
-    	</xsl:for-each>    	
+    	</xsl:for-each>
     </xsl:template>
     
+    <!--
+    	Makro pro jednoduché tabulky
+    -->
+    <xsl:template match="m:tabulka">
+    	<table>
+    		<xsl:variable name="data" select="replace(replace(text(), '^\s+', ''),'\s+$','')"/>
+    		<xsl:variable name="hlavička" select="substring-before($data, '&#10;')"/>
+    		<xsl:variable name="tělo" select="substring-after($data, '&#10;')"/>
+    		<thead>
+    			<tr>
+    				<xsl:for-each select="tokenize($hlavička, ';')">
+						<td><xsl:value-of select="normalize-space(.)"/></td>
+					</xsl:for-each>
+    			</tr>
+    		</thead>
+    		<tbody>
+				<xsl:for-each select="tokenize($tělo, '\n')">
+					<xsl:if test="normalize-space(.)">
+						<tr>
+							<xsl:for-each select="tokenize(., ';')">
+								<td><xsl:value-of select="normalize-space(.)"/></td>
+							</xsl:for-each>
+						</tr>
+					</xsl:if>
+				</xsl:for-each>
+    		</tbody>
+    	</table>    
+    </xsl:template>
 
 </xsl:stylesheet>