This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Carlos problem
- From: "Macaulay,Malcolm (US)" <Malcolm dot Macaulay2 at cnare dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Cc: <linux at lpis dot com>
- Date: Thu, 9 May 2002 07:26:17 -0500
- Subject: [xsl] RE: Carlos problem
- Reply-to: xsl-list at lists dot mulberrytech dot com
Carlos,
The following works OK, but it's not very pretty and I have not tried it work sorting. I'm sure someone will come up with something better.
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table>
<tr>
<td>name</td>
<td>value</td>
<td>name</td>
<td>value</td>
<td>name</td>
<td>value</td>
</tr>
<xsl:for-each select="/ARTS/ART">
<xsl:if test="position() mod 3 = 1 or position()=1">
<xsl:call-template name="Make3ColumnRow">
<xsl:with-param name="FirstItemPositionNo">
<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="Make3ColumnRow">
<xsl:param name="FirstItemPositionNo"/>
<tr>
<td>
<xsl:value-of select="/ARTS/ART[position()=$FirstItemPositionNo]/NAME"/>
</td>
<td>
<xsl:value-of select="/ARTS/ART[position()=$FirstItemPositionNo]/VALUE"/>
</td>
<td>
<xsl:value-of select="/ARTS/ART[position()=$FirstItemPositionNo+1]/NAME"/>
</td>
<td>
<xsl:value-of select="/ARTS/ART[position()=$FirstItemPositionNo+1]/VALUE"/>
</td>
<td>
<xsl:value-of select="/ARTS/ART[position()=$FirstItemPositionNo+2]/NAME"/>
</td>
<td>
<xsl:value-of select="/ARTS/ART[position()=$FirstItemPositionNo+2]/VALUE"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
OUTPUT (look like):
name value name value name value
1 11 2 22 3 33
4 44 5 55 6 66
7 77 8 88
cheers
Malcolm
-----Original Message-----
From: Carlos [mailto:linux@lpis.com]
Sent: 09 May 2002 03:56
To: XSL-List@lists.mulberrytech.com
Subject:
If i have, i have writted bellow xml file, how can i present this file in
this form:
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
this is my intention:
to format the xml file in a html but only with 3 celds but x rows.
if i make a foreach i only know ,to writte i a celd, only one row, but i
want to writte in three celds.
is posible?
can anybody helps me?
thanks
############
XML FILE
############
<?xml version="1.0" encoding="UTF-8"?>
<ARTS>
<ART>
<NAME>1
</NAME>
<VALUE>11
</VALUE>
</ART>
<ART>
<NAME>2
</NAME>
<VALUE>22
</VALUE>
</ART>
<ART>
<NAME>3
</NAME>
<VALUE>33
</VALUE>
</ART>
<ART>
<NAME>4
</NAME>
<VALUE>44
</VALUE>
</ART>
<ART>
<NAME>5
</NAME>
<VALUE>55
</VALUE>
</ART>
<ART>
<NAME>6
</NAME>
<VALUE>66
</VALUE>
</ART>
<ART>
<NAME>7
</NAME>
<VALUE>77
</VALUE>
</ART>
<ART>
<NAME>8
</NAME>
<VALUE>88
</VALUE>
</ART>
</ARTS>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list