|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL for 2 Side by Side columns with flow from top
On Fri, 21 Jan 2005 11:32:49 -0800 (PST), samir sawant
<cindy_mona@xxxxxxxxx> wrote:
> Hi I am looking to convert the Large XML file with > 6 fields into 2 columns. > Each row has 6 fields. > > I want out put in below format: > > Row1 Row(n+1) > Row2 .... > Row3 .... > Row4 .... > .... .... > .... .... > .... .... > Row(n) Row(2n) Hi, Because you not provided a sample XML extract, I will solve the problem for this one: <the_large_XML>
<row><field>1</field><field>2</field><field>3</field><field>4</field><field>5</field><field>6</field></row>
<row><field>a1</field><field>a2</field><field>a3</field><field>a4</field><field>a5</field><field>a6</field></row>
<row><field>b1</field><field>b2</field><field>b3</field><field>b4</field><field>b5</field><field>b6</field></row>
<row><field>c1</field><field>c2</field><field>c3</field><field>c4</field><field>c5</field><field>c6</field></row>
<row><field>d1</field><field>d2</field><field>d3</field><field>d4</field><field>d5</field><field>d6</field></row>
<row><field>e1</field><field>e2</field><field>e3</field><field>e4</field><field>e5</field><field>e6</field></row>
</the_large_XML>The following stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:param name="columns" select="2"/> <xsl:variable name="size" select="ceiling(count(the_large_XML/row) div $columns)"/> <xsl:template match="the_large_XML">
<table>
<xsl:apply-templates select="row[position() <= $size]"/>
</table>
</xsl:template><xsl:template match="row">
<tr>
<xsl:apply-templates select="." mode="col"/>
</tr>
</xsl:template><xsl:template match="row" mode="col"> <td> <xsl:apply-templates select="*"/> </td> <xsl:apply-templates select="following-sibling::row[position()=$size]" mode="col"/> </xsl:template> </xsl:stylesheet>
This is probably not really what you want, so provide more details of the output you're expecting.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








