473,386 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XSL: creating a <UL> within a <TABLE>

I am looping through a list of categories and want to display the list
horizontally (instead of vertically). I want to create a single row
with 4 list items in each cell of the row.

I thought this would work but I get this error:
"End tag 'xsl:if' does not match the start tag 'ul'."

Any thoughts?
<table border="1">
<tr>
<xsl:for-each select="category">
<!-- START CELL & LIST -->
<xsl:if test="position() = 1">
<td><ul>
</xsl:if>

<!-- LIST CATEGORY NAME -->
<li><xsl:value-of select="@name"/></li>

<!-- IF 4 LISTED: CLOSE LIST/CELL AND START NEW CELL -->
<xsl:if test="position() mod 4 = 0 and position() != last()">
</ul></td><td><ul>
</xsl:if>

<!-- CLOSE CELL IF LAST ITEM -->
<xsl:if test="position() = last()">
</ul></td>
</xsl:if>

</xsl:for-each>
</tr>
</table>

Jul 20 '05 #1
8 4620
Can you post a sample input and desired output?

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

"bearclaws" <go**********@bencannon.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am looping through a list of categories and want to display the list
horizontally (instead of vertically). I want to create a single row
with 4 list items in each cell of the row.

I thought this would work but I get this error:
"End tag 'xsl:if' does not match the start tag 'ul'."

Any thoughts?
<table border="1">
<tr>
<xsl:for-each select="category">
<!-- START CELL & LIST -->
<xsl:if test="position() = 1">
<td><ul>
</xsl:if>

<!-- LIST CATEGORY NAME -->
<li><xsl:value-of select="@name"/></li>

<!-- IF 4 LISTED: CLOSE LIST/CELL AND START NEW CELL -->
<xsl:if test="position() mod 4 = 0 and position() != last()">
</ul></td><td><ul>
</xsl:if>

<!-- CLOSE CELL IF LAST ITEM -->
<xsl:if test="position() = last()">
</ul></td>
</xsl:if>

</xsl:for-each>
</tr>
</table>

Jul 20 '05 #2
Tempore 20:39:42, die Friday 18 February 2005 AD, hinc in foro {comp.text.xml} scripsit bearclaws <go**********@bencannon.com>:
I am looping through a list of categories and want to display the list
horizontally (instead of vertically). I want to create a single row
with 4 list items in each cell of the row.

<table border="1">
<tr>
<xsl:for-each select="category">
<!-- START CELL & LIST -->
<xsl:if test="position() = 1">
<td><ul>
</xsl:if>

<!-- LIST CATEGORY NAME -->
<li><xsl:value-of select="@name"/></li>

<!-- IF 4 LISTED: CLOSE LIST/CELL AND START NEW CELL -->
<xsl:if test="position() mod 4 = 0 and position() != last()">
</ul></td><td><ul>
</xsl:if>

<!-- CLOSE CELL IF LAST ITEM -->
<xsl:if test="position() = last()">
</ul></td>
</xsl:if>

</xsl:for-each>
</tr>
</table>

Hi,

Firstly, XSLT is written in XML. This document snippet is certainly not well-formed xml and will therefore never pass through parse stage.
Secondly, the algorithm you're trying to express cannot work in XSLT. In Xslt you can't create tags; you create nodes. These creations are atomic and cannot possibly be split in two halves.

The solution to your problem is grouping.
Here's one example of working code:

<table border="1">
<tr>
<xsl:for-each select="category[(position() -1) mod 4 = 0]">
<td><ul>
<xsl:for-each select=". | following-sibling::category[position() &lt; 4]">
<li><xsl:value-of select="@name"/></li>
</xsl:for-each>
</ul></td>
</xsl:for-each>
</tr>
</table>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Quot capita, tot sententiae" - Terentius , Phormio 454
Jul 20 '05 #3
Joris -
Your solution worked perfectly!

I figured it had something to do with the separated tags but couldn't
find any solid examples online.

Many thanks,
BC

Jul 20 '05 #4
Joris -

Your solution worked perfectly!

I figured it had something to do with the separated tags but couldn't
find any solid examples online.

Many thanks,
BC

Jul 20 '05 #5
Joris -

Your solution worked perfectly!

I figured it had something to do with the separated tags but couldn't
find any solid examples online.

Many thanks,
BC

Jul 20 '05 #6
On 18 Feb 2005 11:39:42 -0800, "bearclaws"
<go**********@bencannon.com> wrote:
I am looping through a list of categories and want to display the list
horizontally (instead of vertically).


Then use CSS to control the presentation of the <ul>, don't mess with
tables.

Jul 20 '05 #7
Tempore 17:44:14, die Saturday 19 February 2005 AD, hinc in foro {comp.text.xml} scripsit Andy Dingley <di*****@codesmiths.com>:
I am looping through a list of categories and want to display the list
horizontally (instead of vertically).


Then use CSS to control the presentation of the <ul>, don't mess with
tables.

I completely agree

--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum
Jul 20 '05 #8
Good thinking. Using CSS works too (and spares me the table logic
mess).

Here are two articles I found helpful for creating multiple column
lists using CSS:

http://www.communitymx.com/content/a...F87&print=true

http://pikasoftware.net/docs/index.p...e_Column_Lists

Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Akseli Mäki | last post by:
Hi, the subject say quite a lot. I have about the following code(4.01 transitional): <p>blaa blaa blaa <ul> <li><a href="foo.html">foo</a></li> <li><a href="bar.html">bar</a></li> </ul>
34
by: Mark Moore | last post by:
It looks like there's a pretty serious CSS bug in IE6 (v6.0.2800.1106). The HTML below is validated STRICT HTML 4.01 and renders as I would expect in Opera, FrontPage, and Netscape. For some...
1
by: Randall Sell | last post by:
OK, I am utterly stumped. The code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css"> ul {...
12
by: toylet | last post by:
Given this list of data: a1 a2 a3 b1 b2 b3 How could I tabulate them without using a table? I knew I could use a <ul> to list one column list, but how about multiple columns? -- .~. ...
8
by: slim | last post by:
hi again all, i am still working on the website as mentioned in earlier threads and have hit another snag... http://awash.demon.co.uk/index.php http://awash.demon.co.uk/vd.css the php is...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
3
by: abro | last post by:
Problem: A list contained in a div contains several items that are made of two parts: itemName and itemValue. ie: <div id="data"> <li>longtime1 <span> 1326 mins></span></li> <li>longtime2...
2
by: Jerry | last post by:
I've got a website that uses an external style sheet to manage several of the design elements. One of the webpages includes an unordered list. I would like for the list to not be indented at all,...
3
by: Man-wai Chang | last post by:
A 2 columns x 10 rows matrix input form <ul> <li> <ul> <li>item name 1 <li><input type="textbox" name="input_col_1_row_1"> <li><input type="textbox" name="input_col_1_row_2"> </ul> <li>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.