<!-- Tento kód je komukoliv k dispozici pro volné použití za libovolných podmínek. Copyleft 2005 Pachollini. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml">
		
	<xsl:output doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" method = "xml" version="1.0" encoding="utf-8" omit-xml-declaration="no" indent="yes"  />
	
	<!-- vyhází přebytečné spany -->
	<xsl:template match="*[local-name()='span']">
		<xsl:apply-templates select="child::*|text()"/>
	</xsl:template>
	
	<!-- zkopíruje neprázdné elementy -->
	<xsl:template match="*">
		<xsl:if test="child::* or normalize-space(translate(text(),' ',''))"><xsl:copy><xsl:apply-templates select="*|attribute::*|text()"/></xsl:copy></xsl:if>
	</xsl:template>
	
	<!-- zachová prázdné elementy -->
	<xsl:template match="*[local-name()='br']|*[local-name()='hr']|*[local-name()='meta']">
		<xsl:copy><xsl:apply-templates select="attribute::*"/></xsl:copy>
	</xsl:template>
	
	<!-- zkopíruje atributy -->
	<xsl:template match="attribute::*">
		<xsl:copy-of select="."/>
	</xsl:template>
	
	<!-- následující 3 pravidla se sanží o rozumné formátování zdrojových kódů -->
	<xsl:template match="*[contains(@class,'SourceText')]">
		<code>
			<xsl:apply-templates/>
			<xsl:apply-templates select="../following-sibling::*/*[contains(@class,'SourceText')]" mode="add-code"/>
		</code>
	</xsl:template>
	
	<xsl:template match="*" mode="add-code">
		<br/><xsl:apply-templates/>
	</xsl:template>
	
	<xsl:template match="*[ancestor::*[contains(@class,'SourceText')]] | *[child::*[contains(@class,'SourceText')]]">
		<xsl:apply-templates/>
	</xsl:template>
	
	<!-- Vyhází přebytečné elementy a atributy -->
	<xsl:template match="@style|@class|@dir|*[local-name()='style'] | *[contains(@class,'SourceText')][preceding-sibling::*[1][contains(@class,'SourceText')] or ../preceding-sibling::*[1]/descendant::*[contains(@class,'SourceText')]]"/>
	
</xsl:stylesheet>