Subject: [xsl] not standart table in stylesheet, need advise From: Andrey Solonchuk <solo@xxxxxxxxxxxxxx> Date: Thu, 27 Feb 2003 18:18:35 +0200 |
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| I have next xml <root> <list flag="2"> <month>5</month> <days>24.00</days> <sname>asdg</sname> <code-pMT>1</code-pMT> <sum-amt>2190.99</sum-amt> </list> <list flag="2"> <month>4</month> <days>10.00</days> <sname>asfgasf</sname> <code-pMT>16</code-pMT> <sum-amt>193.00</sum-amt> </list> <list flag="1"> <month>4</month> <days>0.00</days> <sname>asfg</sname> <code-pMT>200</code-pMT> <sum-amt>500.00</sum-amt> </list> <list flag="1"> <month>4</month> <days>0.00</days> <sname>asfgas</sname> <code-pMT>202</code-pMT> <sum-amt>138.72</sum-amt> </list> <list flag="1"> <month>3</month> <days>0.00</days> <sname>asdfga</sname> <code-pMT>202</code-pMT> <sum-amt>11811.73</sum-amt> </list> </root> my xsl work by in my sigth is very ugly <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" > <xsl:strip-space elements="*"/> <xsl:output method="html" encoding="Windows-1251" xalan:indent-amount="5"/> <xsl:template match="/root"> <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:variable name="flag1" select="list-charg-stop-fact-code-print-form[@flag=2]"/> <xsl:variable name="flag2" select="list-charg-stop-fact-code-print-form[@flag=1]"/> <xsl:variable name="loopflag"> <xsl:choose> <xsl:when test="count($flag1) > count($flag2)"> <xsl:value-of select="2"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="1"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="loop" select="list-charg-stop-fact-code-print-form[@flag=$loopflag]"/> <xsl:for-each select="$loop"> <xsl:variable name="i" select="position()"/> <tr> <th><xsl:value-of select="$flag1[position()=$i]/code-pMT"/></th> <th><xsl:value-of select="$flag1[position()=$i]/sname"/></th> <th><xsl:value-of select="$flag1[position()=$i]/sum-amt"/></th> <th><xsl:value-of select="$flag1[position()=$i]/days"/></th> <th><xsl:value-of select="$flag2[position()=$i]/code-pMT"/></th> <th><xsl:value-of select="$flag2[position()=$i]/sname"/></th> <th><xsl:value-of select="$flag2[position()=$i]/sum-amt"/></th> </tr> </xsl:for-each> <tr valign="bottom"> <th></th> <th></th> <th><xsl:value-of select="format-number(sum($flag1/sum-amt),'.00')"/></th> <th><xsl:value-of select="sum($flag1/days)"/></th> <th></th> <th></th> <th><xsl:value-of select="format-number(sum($flag2/sum-amt),'.00')"/></th> </tr> </table> </body> </html> </xsl:template> </xsl:stylesheet> -- Best regards, Andrey mailto:solo@xxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Fw: Select entire XML doc, Karl Stubsjoen | Thread | Re: [xsl] not standart table in sty, Kevin Jones |
Re: [xsl] Select entire XML doc, Oleg Tkachenko | Date | [xsl] XSL-List Guidelines, Mulberry Technologie |
Month |