473,231 Members | 1,709 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,231 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 4611
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.