Displaying tables based on multiple conditions in XSLT - xslt-1.0

I have five values that come from a form; like state1, state2, state3, state4, and state5.
Each value can be either 'New' or 'Closed'.
A Report will be displayed based on these values.
So, I created 5 tables, one each to be displayed on the report.
If a value is 'New' then display the respective table else no need to display.
So, I created XSLT like the below (this is just a fragment from my code).
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes" standalone="yes" indent="yes"cdata-section-elements="script msxsl:script"></xsl:output>
<xsl:template match="/">
<html>
<head><title>Report</title></head>
<body>
<table class="row1">
<tr>
<td align="left" colspan="2">
<img src="../images/Logos/logo.gif" height="80"></img>
</td>
</tr>
</table>
<xsl:if test="(state1='New') and (state2='Closed') and (state3='Closed') and (state4='Closed') and (state5='Closed')">
<table class="row2">
<tr>
<td class="section" uniqueID="ms__id17">
<b>Details(S1)</b>
</td>
</tr>
<!--some rows -->
</table>
</xsl:if>
<xsl:if test="(state1='New') and (state2='New') and (state3='Closed') and (state4='Closed') and (state5='Closed')">
<table class="row2">
<tr>
<td class="section" uniqueID="ms__id18">
<b>Details(S1)</b>
</td>
</tr>
<!--some rows -->
</table>
<table class="row3">
<tr>
<td class="section" uniqueID="ms__id19">
<b>Details(S2)</b>
</td>
</tr>
<!--some rows -->
</table>
</xsl:if>
<!--more conditions-->
</body>
</html>
</xsl:template>
</xsl:stylesheet>
If I keep on giving conditions like this I should give 5! conditions.
Is there a better way of doing this.

Is this what you want (use or instead of and)?
<xsl:if test="(state1='New') or (state2='New') or (state3='New') or (state4='New') or (state5='New')">
<table class="row2">
<tr>
<td class="section" uniqueID="ms__id17">
<b>Details(S1)</b>
</td>
</tr>
<!--some rows -->
</table>
</xsl:if>

Related

xslt - grouping element and following element

I have the following structure. That is to say - I may have the following structure.
The output comes from a CMS and very often there is text in front of a table and after a table. In order to make the second stage in the transformation work, wrapping the the paragraph before the table and after the table inside an element is essential.
<?xml version="1.0" encoding="UTF-8"?>
<div>
<p>some text here</p>
<p>and maybe some text here. it may or may not be here</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>Likely to be a paragraph here</p>
<p>And here - often like: table 2, but nothing I can use</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>and another paragraph at the end of the table</p>
</div>
My goal is to get an output like below where the first paragraph in the beginning has it's own wrapper. then the combination of paragraph + table + paragraph is put inside a wrapper.
There might be some paragraphs at the end of the file and those should be wrapped as well.
<?xml version="1.0" encoding="UTF-8"?>
<body>
<div>
<p>some text here</p>
</div>
<div class="table">
<p>and maybe some text here. it may or may not be here</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>Likely to be a paragraph here</p>
</div>
<div class="table">
<p>And here - often like: table 2, but nothing I can use</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>another text at the end of the table</p>
</div>
</body>
I am playing around with preceding and following + parent. Any pointers in the right direction would be of great help
I am restricted to XSLT 1.0.
I don't think the problem is well-defined. Given certain assumptions (which should be self-evident), and given a well-formed input such as:
XML
<body>
<p>some text here</p>
<p>and maybe some text here. it may or may not be here</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>Likely to be a paragraph here</p>
<p>And here - often like: table 2, but nothing I can use</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>and another paragraph at the end of the table</p>
</body>
you could do something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="body">
<xsl:copy>
<xsl:apply-templates select="p[not(preceding-sibling::*[1][self::figure] or following-sibling::*[1][self::figure])]" mode="stand-alone"/>
<xsl:for-each select="figure">
<div class="table">
<xsl:copy-of select="preceding-sibling::*[1][self::p]"/>
<xsl:copy-of select="."/>
<xsl:copy-of select="following-sibling::*[1][self::p]"/>
</div>
</xsl:for-each>
</xsl:copy>
</xsl:template>
<xsl:template match="p" mode="stand-alone">
<div>
<xsl:copy-of select="."/>
</div>
</xsl:template>
</xsl:stylesheet>
to get:
Result
<body>
<div>
<p>some text here</p>
</div>
<div class="table">
<p>and maybe some text here. it may or may not be here</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>Likely to be a paragraph here</p>
</div>
<div class="table">
<p>And here - often like: table 2, but nothing I can use</p>
<figure>
<table>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</figure>
<p>and another paragraph at the end of the table</p>
</div>
</body>

XSL Display attribute after a certain character

I Have a Attribute that I want to display, but I only want to display the last portion of it indicated by an "-". I am using substring-after to do this but this only works if there is one charactor. There are occasions where there might be one and some where there is two. I have seen some recursive templates for this but I have not seen them in a For-each Loop like I have it here and I am not sure where I would put everything in my XSL document.
Here is my XML document:
<?xml version="1.0" encoding="UTF-8"?>
<JobList>
<Job T.number="28" />
<Job T.identifier="10mm Drill" />
<Job oper.jobName="2: T28-Contour Milling - Grind me back" />
<Job T.number="3" />
<Job T.identifier="9mm Drill" />
<Job oper.jobName="3: T3 Contour Milling" />
</JobList>
Here is my XSL Document. I am using XSL 1.0. The result I am looking for is I want this to be displayed as "10mm Drill - Grind me back" not "10mm Drill-Contour Milling - Grind me back" which is what I am getting now using the substring-after function or something with the same result.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" encoding="UTF-8" method="xml" />
<xsl:param name="REPORT">joblist</xsl:param>
<xsl:param name="LOCALE">en-GB</xsl:param>
<xsl:param name="FORMAT">html</xsl:param>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Tool Report</title>
</head>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="JobList">
<div style="font-size:;">
<table width="100%" style="margin-bottom:50px;font:bold 10px arial;">
<thead>
<tr>
<th style="text-align:center;font-family:Arial;font-size:13;font:bold 7px arial;">
<xsl:value-of select="#month">
</xsl:value-of>
<span>.</span>
<xsl:value-of select="#day">
</xsl:value-of>
<span>.</span>
<xsl:value-of select="#year">
</xsl:value-of>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center;font:normal 7px arial;font-size:12px;">
<xsl:value-of select="//Job[position()=1]/#cfg.JOBLISTNAME" />
<span>
</span>
<span>
</span>
</td>
</tr>
</tbody>
<table width="100%" border="1" style="margin-bottom:50px;font:13px arial;">
<thead style="font:19;">
<tr style="font-size:19;">
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
<td style="text-align:center;font-weight:bold;font-size:19;">
</td>
</tr>
</thead>
<tbody style="font-size:19;">
<xsl:for-each select="//Job[not(#T.number=preceding::Job/#T.number)]">
<tr style="font-size:19;">
<td style="font-size:19;">
<xsl:value-of select="#T.number" />
</td>
<td>
</td>
<td style="font-size:19;">
<xsl:value-of select="#T.identifier" />
<xsl:choose>
<xsl:when test="contains(#T.toolComment3, 'GRIND') or contains(#T.toolComment3, 'Grind')">
<xsl:value-of select="#T.toolComment3" />
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(#T.comment2, 'GRIND') or contains(#T.comment2, 'Grind')">
<xsl:value-of select="#T.comment2" />
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="contains(#oper.jobName, 'GRIND') or contains(#oper.jobName, 'Grind')">
<xsl:value-of select="substring-after(#oper.jobName, '-')" />
</xsl:when>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</table>
</div>
</xsl:template>
</xsl:stylesheet>
Use a named recursive template to get the last token of the text string.
<xsl:template name="last-token">
<xsl:param name="text"/>
<xsl:param name="delimiter" select="'-'"/>
<xsl:choose>
<xsl:when test="contains($text, $delimiter)">
<!-- recursive call -->
<xsl:call-template name="last-token">
<xsl:with-param name="text" select="substring-after($text, $delimiter)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Example of call: http://xsltransform.net/bFWR5Ew

IF clause is not being detected in XSL script

I have this simple template:
<!--Item-->
<xsl:template match="Presentations|TFGWItem">
<tr>
<xsl:apply-templates select="Theme"/>
<xsl:apply-templates select="Name" />
</tr>
<xsl:if test="name()='Presentations'">
<tr>
<td>
<xsl:text> </xsl:text>
</td>
<td>
<xsl:text> </xsl:text>
</td>
</tr>
<tr>
<td>
<xsl:text> </xsl:text>
</td>
<td>
<xsl:text> </xsl:text>
</td>
</tr>
</xsl:if>
</xsl:template>
But the if clause is not processing. Am I doing the if test incorrectly?
Turns out that the test was working. It was just that the empty rows were not getting displayed in the browser.
I had to change it:
<!--Item-->
<xsl:template match="LACItem|Presentations|TFGWItem">
<tr>
<xsl:apply-templates select="Theme"/>
<xsl:apply-templates select="Name" />
</tr>
<xsl:if test="name()='Presentations'">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</xsl:if>
</xsl:template>

Grouping SQL elements with XSL

I've been working on a XSL style sheet for a specific SQL query table. I would like to group the results by 'tcode' and sum the values of each of the number columns. Any help would be appreciated.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="h_ind h_year h_code" />
<xsl:variable name="v_warning" select="CustomDeferredReport/title/ds_type" />
<xsl:template match="/">
<HTML>
<BODY>
<TABLE>
<TR valign="top">
<TD style="color:black; font-family: arial; font-size: 14pt; font-weight: bold" width="800">
<xsl:choose>
<xsl:when test="$v_warning = '1'">
<xsl:value-of select="CustomDeferredReport/title/rpt_title" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="CustomDeferredReport/title/rpt_warning" />
</xsl:otherwise>
</xsl:choose>
</TD>
</TR>
</TABLE>
<xsl:choose>
<xsl:when test="$v_warning = 1">
<TABLE>
<TR style="text-decoration: underline; font-family: arial; font-size: 8pt; font-weight: bold">
<BOLD>
<TD width="100">Code</TD>
<TD width="200">Name</TD>
<TD width="100">Beginning Balance</TD>
<TD width="100">Current Activity</TD>
<TD width="100">Other Activity</TD>
<TD width="100">Balance Sheet Only Activity</TD>
<TD width="100">Ending Balance</TD>
</BOLD>
</TR>
<xsl:for-each select='/CustomDeferredReport/temps'>
<TR style="font-family: arial; font-size: 8pt">
<TD><xsl:value-of select='tcode'/></TD>
<TD><xsl:value-of select='tname'/></TD>
<TD align="right"><xsl:value-of select='tbbal'/></TD>
<TD align="right"><xsl:value-of select='tdiff'/></TD>
<TD align="right"><xsl:value-of select='tothd'/></TD>
<TD align="right"><xsl:value-of select='tbsd'/></TD>
<TD align="right"><xsl:value-of select='tebal'/></TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Here you go.
In XSLT there is a very common grouping technique you can use that involves a key and the generate-id() function, it is called muenchian grouping (Google it).
Anyhow, I added a key at the top of your solution called, key_t-code, and then use it several times in the solution. The trick here is when itterating over the for-each loop to only do something, in your case sum the nodes when you encounter the loop the first time, achieved by using the key and the generate-id. Enough said. An example is worth a thousand words. Here you go... oh, I did have to correct your XSLT n a couple of places. Mostly your context was off here and there.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="h_ind h_year h_code" />
<xsl:key name="key_t-code" match="temps" use="tcode"/>
<xsl:variable name="v_warning" select="/CustomDeferredReport/title/ds_type" />
<xsl:template match="/">
<HTML>
<BODY>
<TABLE>
<TR valign="top">
<TD style="color:black; font-family: arial; font-size: 14pt; font-weight: bold" width="800">
<xsl:choose>
<xsl:when test="$v_warning = '1'">
<xsl:value-of select="CustomDeferredReport/title/rpt_title" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="CustomDeferredReport/title/rpt_warning" />
</xsl:otherwise>
</xsl:choose>
</TD>
</TR>
</TABLE>
<xsl:choose>
<xsl:when test="$v_warning = 1">
<TABLE>
<TR style="text-decoration: underline; font-family: arial; font-size: 8pt; font-weight: bold">
<BOLD>
<TD width="100">Code</TD>
<TD width="200">Name</TD>
<TD width="100">Beginning Balance</TD>
<TD width="100">Current Activity</TD>
<TD width="100">Other Activity</TD>
<TD width="100">Balance Sheet Only Activity</TD>
<TD width="100">Ending Balance</TD>
</BOLD>
</TR>
<xsl:for-each select='CustomDeferredReport/temps'>
<xsl:if test="generate-id(key('key_t-code', tcode)[1]) = generate-id(.)">
<TR style="font-family: arial; font-size: 8pt">
<TD><xsl:value-of select='tcode'/></TD>
<TD><xsl:value-of select='tname'/></TD>
<TD align="right"><xsl:value-of select="sum(key('key_t-code', tcode)/tbbal)"/></TD>
<TD align="right"><xsl:value-of select="sum(key('key_t-code', tcode)/tdiff)"/></TD>
<TD align="right"><xsl:value-of select="sum(key('key_t-code', tcode)/tothd)"/></TD>
<TD align="right"><xsl:value-of select="sum(key('key_t-code', tcode)/tbsd)"/></TD>
<TD align="right"><xsl:value-of select="sum(key('key_t-code', tcode)/tebal)"/></TD>
</TR>
</xsl:if>
</xsl:for-each>
</TABLE>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
And the Xml
<?xml version="1.0" encoding="UTF-8"?>
<CustomDeferredReport>
<title>
<ds_type>1</ds_type>
<rpt_title>some title rpt_title</rpt_title>
<rpt_warning>some title rpt_warning</rpt_warning>
</title>
<temps>
<tcode>AAA</tcode>
<tname>Tripel A</tname>
<tbbal>9.99</tbbal>
<tdiff>.24</tdiff>
<tothd>23</tothd>
<tbsd>5.00</tbsd>
<tebal>62</tebal>
</temps>
<temps>
<tcode>AAA</tcode>
<tname>Tripel A</tname>
<tbbal>3.99</tbbal>
<tdiff>1.24</tdiff>
<tothd>2.03</tothd>
<tbsd>50.00</tbsd>
<tebal>63.23</tebal>
</temps>
<temps>
<tcode>AAA</tcode>
<tname>Tripel A</tname>
<tbbal>.99</tbbal>
<tdiff>24</tdiff>
<tothd>2.3</tothd>
<tbsd>500</tbsd>
<tebal>65.23</tebal>
</temps>
<temps>
<tcode>BB</tcode>
<tname>Double B</tname>
<tbbal>2</tbbal>
<tdiff>.24</tdiff>
<tothd>23</tothd>
<tbsd>5.00</tbsd>
<tebal>62</tebal>
</temps>
<temps>
<tcode>BB</tcode>
<tname>Double B</tname>
<tbbal>4</tbbal>
<tdiff>11.24</tdiff>
<tothd>28.03</tothd>
<tbsd>5.23</tbsd>
<tebal>.26</tebal>
</temps>
<temps>
<tcode>BB</tcode>
<tname>Double A</tname>
<tbbal>6</tbbal>
<tdiff>32</tdiff>
<tothd>223</tothd>
<tbsd>6.7</tbsd>
<tebal>12.23</tebal>
</temps>
</CustomDeferredReport>
To run this solution separate of your environment, so to see this run in a browser locally, just add the following deceleration just below the existing xml declaration in your Xml (and to be safe, use my Xml).
<?xml-stylesheet type='text/xsl' href='tcode.xsl'?>
Take the XSLT I have written and save it to disk and name it tcode.xsl. This transformation should work lickity split in IE but if you insist on running it in Chrome, well you have to set a flag that enables local files to run... --allow-file-access-from-files
After adding the xml-stylesheet deceleration to your Xml, drag the Xml into an IE browser and it should transform it.

Table with fixed number of rows (xslt, sql)

I have problem with setting fixed number of rows in my table.
I created table with similar code with this one:
<xsl:for-each select="DBData/tabulka1/Row[position() < 14]">
<tr>
<td><xsl:value-of select="ODESILATEL"/></td>
<td><xsl:value-of select="PREDMET"/></td>
<td align="right" class="sOkrajem"></td>
</tr>
</xsl:for-each>
And I need to fix number of rows to 15, even if I get a few records.
To example, if I get only 13 rows from database, so the two left rows will be empty, but will be there. For better understand, here is image:
http://imageshack.us/photo/my-images/692/tabulkar.png/
If will be neccesary, I can edit my SQL code.
Thanks for all advice. And sorry for representation of my problem.
edit. more extensive example of my code:
I have problem with setting fixed number of rows in my table.
I created table with similar code with this one:
<xsl:for-each select="DBData/tabulka1/Row[position() < 14]">
<tr>
<td><xsl:value-of select="ODESILATEL"/></td>
<td><xsl:value-of select="PREDMET"/></td>
<td align="right" class="sOkrajem"></td>
</tr>
</xsl:for-each>
And I need to fix number of rows to 15, even if I get a few records.
To example, if I get only 13 rows from database, so the two left rows will be empty, but will be there. For better understand, here is image:
http://imageshack.us/photo/my-images/692/tabulkar.png/
If will be neccesary, I can edit my SQL code.
Thanks for all advice. And sorry for representation of my problem.
edit. more extensive example of my latest use of code:
<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="RolesPath" select="'%RolesPath%'"/>
<xsl:decimal-format decimal-separator=","
grouping-separator=" "/>
<xsl:include href="%RolesPath%\_foot.xsl" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta name="lang" content="cs" />
<meta http-equiv="Content-Type" content="text/xml; charset=windows-1250" />
<meta name="copyright" content="© 2009-2010 Flores" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body class ="teloBezObrazku">
<table width="95%" class="tabulka">
<th colspan="3" class="nadpis">Vzkazy</th>
<xsl:variable name="numRows" select="15" />
<xsl:variable name="rows" select="DBData/tabulka1/Row" />
<xsl:apply-templates select="$rows[position() <= $numRows]" />
<xsl:call-template name="AddRows">
<xsl:with-param name="numRows" select="$numRows - count($rows)" />
</xsl:call-template>
</table>
<span style="position: absolute; bottom: 10;">
  Otevřít vše...<b class="cara">|</b> 
Nový...
</span>
<xsl:call-template name="footer">
<xsl:with-param name="RolesPath" select="'%RolesPath%'"/>
</xsl:call-template>
</foot>
</html>
</xsl:template>
<!-- Separate templates -->
<xsl:template name="TableRow" match="tabulka1/Row">
<tr>
<td>
<xsl:value-of select="self::Row/ODESILATEL"/>
</td>
<td>
<xsl:value-of select="self::Row/PREDMET"/>
</td>
<td align="right" class="sOkrajem"></td>
</tr>
</xsl:template>
<xsl:template name="AddRows">
<xsl:param name="numRows" />
<xsl:if test="$numRows > 0">
<xsl:call-template name="TableRow" />
<xsl:call-template name="AddRows">
<xsl:with-param name="numRows" select="$numRows - 1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
edit. First line probably getting error.
<xsl:template name="tabulka1 | tabulka1/Row" mode="row">
<tr onmouseover="className='seda'" onmouseout="className='bila'" title="{OBSAH}" style="cursor:hand" xmlns="http://www.w3.org/1999/xhtml">
<a href="abrasite:A4NHDUKJESG4PJAVPQJFMAE2PS,0,DoShow;{ID}">
<xsl:choose>
<xsl:when test = "PRECTENO='N'">
<td align="left" class="sOkrajem"><b><xsl:value-of select="self::Row/ODESILATEL"/></b></td>
<td align="left" class="sOkrajem"><b><xsl:value-of select="self::Row/PREDMET"/></b></td>
<td align="right" class="sOkrajem">
<b><xsl:value-of select="self::Row/DATUM"/> <xsl:value-of select="self::Row/HODINY"/><xsl:value-of select="self::Row/MINUTY"/></b>
</td>
</xsl:when>
<xsl:otherwise>
<td align="left" class="sOkrajem"><xsl:value-of select="self::Row/ODESILATEL"/></td>
<td align="left" class="sOkrajem"><xsl:value-of select="self::Row/PREDMET"/></td>
<td align="right" class="sOkrajem">
<xsl:value-of select="self::Row/DATUM"/> <xsl:value-of select="self::Row/HODINY"/><xsl:value-of select="self::Row/MINUTY"/>
</td>
</xsl:otherwise>
</xsl:choose>
</a>
</tr>
</xsl:template>
You should be able to accomplish it like this (I've omitted the footer parts, which I don't have access to):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="RolesPath" select="'%RolesPath%'"/>
<xsl:decimal-format decimal-separator=","
grouping-separator=" "/>
<xsl:variable name="numRows" select="15" />
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta name="lang" content="cs" />
<meta http-equiv="Content-Type" content="text/xml; charset=windows-1250" />
<meta name="copyright" content="© 2009-2010 Flores" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body class ="teloBezObrazku">
<xsl:apply-templates select="DBData/tabulka1" />
<xsl:apply-templates select="DBData/tabulka2" />
<span style="position: absolute; bottom: 10;">
  Otevřít vše...<b class="cara">|</b> 
Nový...
</span>
</body>
</html>
</xsl:template>
<xsl:template name="TableRows">
<xsl:variable name="rows" select="Row" />
<xsl:apply-templates select="$rows[position() <= $numRows]" mode="row" />
<xsl:call-template name="AddRows">
<xsl:with-param name="numRows" select="$numRows - count($rows)" />
</xsl:call-template>
</xsl:template>
<xsl:template name="AddRows">
<xsl:param name="numRows" />
<xsl:if test="$numRows > 0">
<xsl:apply-templates select="." mode="row" />
<xsl:call-template name="AddRows">
<xsl:with-param name="numRows" select="$numRows - 1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="tabulka1">
<table width="95%" class="tabulka" xmlns="http://www.w3.org/1999/xhtml">
<tr>
<th colspan="3" class="nadpis">Vzkazy</th>
</tr>
<xsl:call-template name="TableRows" />
</table>
</xsl:template>
<xsl:template match="tabulka1 | tabulka1/Row" mode="row">
<tr xmlns="http://www.w3.org/1999/xhtml">
<td>
<xsl:value-of select="self::Row/ODESILATEL"/>
</td>
<td>
<xsl:value-of select="self::Row/PREDMET"/>
</td>
<td align="right" class="sOkrajem"></td>
</tr>
</xsl:template>
<xsl:template match="tabulka2">
<table width="95%" class="tabulka" xmlns="http://www.w3.org/1999/xhtml">
<tr>
<th colspan="2" class="nadpis">Other Table</th>
</tr>
<xsl:call-template name="TableRows" />
</table>
</xsl:template>
<xsl:template match="tabulka2 | tabulka2/Row" mode="row">
<tr xmlns="http://www.w3.org/1999/xhtml">
<td>
<xsl:value-of select="self::Row/ODESILATEL2"/>
</td>
<td>
<xsl:value-of select="self::Row/PREDMET2"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
When run on this input XML:
<DBData>
<tabulka1>
<Row>
<ODESILATEL>Hello</ODESILATEL>
<PREDMET>1</PREDMET>
</Row>
<Row>
<ODESILATEL>Ciao</ODESILATEL>
<PREDMET>2</PREDMET>
</Row>
<Row>
<ODESILATEL>Hi</ODESILATEL>
<PREDMET>3</PREDMET>
</Row>
<Row>
<ODESILATEL>Bonjour</ODESILATEL>
<PREDMET>4</PREDMET>
</Row>
</tabulka1>
<tabulka2>
<Row>
<ODESILATEL2>Konnnichiwa</ODESILATEL2>
<PREDMET>1</PREDMET>
</Row>
<Row>
<ODESILATEL2>Wazzap</ODESILATEL2>
<PREDMET>2</PREDMET>
</Row>
<Row>
<ODESILATEL2>Buenos dias</ODESILATEL2>
<PREDMET>3</PREDMET>
</Row>
</tabulka2>
</DBData>
The result is:
<html xml:lang="cs" lang="cs" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="lang" content="cs" />
<meta http-equiv="Content-Type" content="text/xml; charset=windows-1250" />
<meta name="copyright" content="© 2009-2010 Flores" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body class="teloBezObrazku">
<table width="95%" class="tabulka">
<tr>
<th colspan="3" class="nadpis">Vzkazy</th>
</tr>
<tr>
<td>Hello</td>
<td>1</td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td>Ciao</td>
<td>2</td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td>Hi</td>
<td>3</td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td>Bonjour</td>
<td>4</td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
<tr>
<td></td>
<td></td>
<td align="right" class="sOkrajem" />
</tr>
</table>
<table width="95%" class="tabulka">
<tr>
<th colspan="2" class="nadpis">Other Table</th>
</tr>
<tr>
<td>Konnnichiwa</td>
<td></td>
</tr>
<tr>
<td>Wazzap</td>
<td></td>
</tr>
<tr>
<td>Buenos dias</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
<span style="position: absolute; bottom: 10;">
  Otevřít vše...<b class="cara">|</b> 
Nový...
</span>
</body>
</html>