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

xsl multicolumn table or list layout

Subject: xsl multicolumn table or list layout
From: "Josh Wasserman" <jwass@xxxxxxxxxxxxxxx>
Date: Tue, 27 Feb 2007 16:02:54 -0500
 xsl multicolumn table or list layout
Hi,

I have an xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<members>
<faculty id="1">
 <first_name>John</first_name>
 <last_name>Doe</last_name>
</faculty>
<faculty id="5">
 <first_name>Jane</first_name>
 <last_name>Doe</last_name>
</faculty>
<faculty id="6">
 <first_name>James</first_name>
 <last_name>Smith</last_name>
</faculty>
<faculty id="7">
 <first_name>Jane</first_name>
 <last_name>Jones</last_name>
</faculty>
<faculty id="8">
 <first_name>Harvey</first_name>
 <last_name>Wallbanger</last_name>
</faculty>
<faculty id="9">
 <first_name>Lisa</first_name>
 <last_name>Lisa</last_name>
</faculty>
</members>

What I'd like to do is lay these out (with their full name which links to their bio, which is named id.xml (replace id with the id attribute for each)

Basically, each td or li item should look like this: <a href="faculty-bio.jsp?faculty={@id}"><xsl:value-of select="first_name" />&#160;<xsl:value-of select="last_name" /></a> (yes, i use a variable, this is just for simplicity's sake)

I tricked Firefox on a pc using floating divs to make this work:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="members">
<xsl:variable name="emailaddress" select="email"/>
<xsl:variable name="facultyname" select="first_name+''+last_name"/>
<xsl:for-each select="faculty">
<xsl:sort select="last_name" />
<div style="float:left;position:relative;top:15px;clear:right;width:180px;height:20px;"><span style="font-size:9pt; font-weight:bold; color:#003300;"><a href="faculty-bio.jsp?faculty={@id}"><xsl:value-of select="first_name" />&#160;<xsl:value-of select="last_name" /></a></span></div>
</xsl:for-each>
</xsl:template>


Of course this doesn't work in IE for PC. I am aware of the tree/recursive nature of xsl, and have tried to use something like this, which I found in previous posts:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="members">
<xsl:variable name="t-size" select="count(faculty)"/>
<xsl:variable name="half" select="ceiling($t-size div 2)"/>
<table style="width:100%;">
<xsl:for-each select="faculty[position() &lt;= $half]">
<xsl:variable name="here" select="position()"/>
<tr>
<td><a href="faculty-bio.jsp?faculty={@id}"><xsl:value-of select="."/></a></td>
<td>
<xsl:choose>
<xsl:when test="../faculty[$here+$half]">
<xsl:value-of select="../faculty[$here+$half]"/>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>


- but it doesn't work at all.

I would be grateful for any suggestions, help, or proven methods of doing something like this.

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-2011 All Rights Reserved.