[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Transform list of elements to a sorted and dynamic HTM

Subject: Transform list of elements to a sorted and dynamic HTML table
From: Jannis Pohlmann <info@xxxxxxxxxxx>
Date: Sun, 12 Dec 2004 04:58:21 +0100
dynamic htm
Good morning,

I have a list of items, e.g.:

<item>
 <name>Adoreable</name>
 <date>2004-12-11</date>
</item>
<item>
 <name>Adjustable</name>
 <date>2004-12-11</date>
</item>
<item>
 <name>Bulk</name>
 <date>2004-12-10</date>
</item>
<item>
 <name>Condensed</name>
 <date>2004-12-12</date>
</item>
<item>
 <name>Compromise</name>
 <date>2004-11-08</date>
</item>

and I want them to be transformed to a sorted and dynamic (columns and rows adjustable by variables - $Columns and $Rows) HTML table (using recent Version of Saxon and XSLT2.0). The sort element are the <date/>-Elements (descending), so the table output had to look like this ($Columns = 2, $Rows = 2):

<table>
 <tr>
   <td>Condensed</td>
   <td>Adjustable</td>
 </tr>
 <tr>
   <td>Adoreable</td>
   <td>Bulk</td>
 </tr>
 <tr>
   <td colspan="2">Compromise</td>
 </tr>
</table>

If there are not enough items to fill the columns of the last row its last <td> should
have a "colspan" attribute in order to satisfy layout requirements. No empty
rows should be created (e.g. if there are not enough items to fill all <$Rows> rows).

As you may see there exists a second sort element (<name/>, ascending) in my example
but this is no must-have feature.

An alternative way might be to select the first <$Columns * $Rows> items (sorted descendingly by <date/>, of course) - but I see no solution for this, right now.

Is there a way to handle this problem with the power of XSLT?

Regards,
Jannis

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.