473,773 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="categor y">
<!-- START CELL & LIST -->
<xsl:if test="position( ) = 1">
<td><ul>
</xsl:if>

<!-- LIST CATEGORY NAME -->
<li><xsl:valu e-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 4662
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**********@b encannon.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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="categor y">
<!-- START CELL & LIST -->
<xsl:if test="position( ) = 1">
<td><ul>
</xsl:if>

<!-- LIST CATEGORY NAME -->
<li><xsl:valu e-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**********@b encannon.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="categor y">
<!-- START CELL & LIST -->
<xsl:if test="position( ) = 1">
<td><ul>
</xsl:if>

<!-- LIST CATEGORY NAME -->
<li><xsl:valu e-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="categor y[(position() -1) mod 4 = 0]">
<td><ul>
<xsl:for-each select=". | following-sibling::catego ry[position() &lt; 4]">
<li><xsl:valu e-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**********@b encannon.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*****@codesm iths.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
6843
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
11077
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 reason, there's an annoying vertical gap between adjacent rules that doesn't go away. This looks like IE6 is incorrectly setting the margin to some arbitrary value. Does anyone know if this is a known bug at MS? If you know of one, post the...
1
3756
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 { background-color: red; }
12
5138
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? -- .~. Might, Courage, Vision. In Linux We Trust.
8
5157
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 pulling a name and placing it under the thumbnail (the text is
19
17573
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 spacing? Thanks, CMA <div class="vlgray">Condition</div> <table cellpadding="0" cellspacing="0">
3
10773
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 <span> 1692 mins</span></li> <li> time1 <span> 24 mins </span></li>
2
12058
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, with the bullets directly below the left margin of a standard paragraph of text. All of the content is included in a table cell. I was able to accomplish that when viewed in IE, using the following CSS snippet, but both NS and FireFox displays the...
3
6689
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
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.