On Thursday 27 February 2003 16:18, Andrey Solonchuk wrote:
Hi All, help me please find more elegant way to solve next sitiaion
I have xsl that work but it very 'awful'
I need table with the next columns
------------------------------------
| @flag = 1 | @flag=2 |
|code|sname|sum|date|code|sname|sum|
Cut ..
Not sure why you think your solution is 'awful' but I would have probably gone
for a recursive template approach rather than a for-each loop. Something like
this better?
Kev.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<head></head>
<body>
<big>title</big>
<table>
<tr>
<th>codePMT</th>
<th>sName</th>
<th>summa</th>
<th>date</th>
<th>codePMT</th>
<th>sName</th>
<th>summa</th>
</tr>
<xsl:call-template name="output-row">
<xsl:with-param name="part1" select="/root/list[(_at_)flag=2]"/>
<xsl:with-param name="part2" select="/root/list[(_at_)flag=1]"/>
</xsl:call-template>
<tr valign="bottom">
<th></th>
<th></th>
<th><xsl:value-of
select="format-number(sum(/root/list[(_at_)flag=2]/sum-amt),'.00')"/></th>
<th><xsl:value-of
select="sum(/root/list[(_at_)flag=2]/days)"/></th>
<th></th>
<th></th>
<th><xsl:value-of
select="format-number(sum(/root/list[(_at_)flag=1]/sum-amt),'.00')"/></th>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="output-row">
<xsl:param name="part1" select="/.."/>
<xsl:param name="part2" select="/.."/>
<tr>
<th><xsl:value-of select="$part1[1]/code-pMT"/></th>
<th><xsl:value-of select="$part1[1]/sname"/></th>
<th><xsl:value-of select="$part1[1]/sum-amt"/></th>
<th><xsl:value-of select="$part1[1]/days"/></th>
<th><xsl:value-of select="$part2[1]/code-pMT"/></th>
<th><xsl:value-of select="$part2[1]/sname"/></th>
<th><xsl:value-of select="$part2[1]/sum-amt"/></th>
</tr>
<xsl:if test="count($part1)+count($part2) > 0">
<xsl:call-template name="output-row">
<xsl:with-param name="part1"
select="$part1[position()>1]"/>
<xsl:with-param name="part2"
select="$part2[position()>1]"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list