473,405 Members | 2,404 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,405 software developers and data experts.

XSL > HTML table building question

Hi!

I'm looking to generate an HTML table via XSL using XML data.

Specifically, I want to arrange my data in a table with rows of 6
columns. So, I have this conditional XSL statement setup to open and
close <tr>'s when appropriate.

Unfortunately, the XSL parser doesn't like the fact that within the
<xsl:when> block there is no closing tag for <tr>. (ie. Receive the
error message: "End tag 'xsl:when' does not match the start tag
'tr'.")

<code snippet>
<xsl:for-each select="course">
<xsl:choose>
<xsl:when test="position() mod 6 = 1">
<tr> <!-- PROBLEM -->
<td>
SOME DATA
</td>
</xsl:when>
<xsl:when test="position() mod 6 = 0">
<td>
SOME DATA
</td>
</tr> <!-- PROBLEM -->
</xsl:when>
<xsl:otherwise>
<td>
SOME DATA
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</code snippet>

Is there a way to tell the XSL parser that this is what I want and to
leave me alone? Or is there another (better?) way of doing this?

Thanks in advance,
John

P.S. I realize at this point that this code relies on a multiple of 6
<course> blocks in the XML to create well-formed HTML.
Jul 20 '05 #1
6 2435


John Kooistra wrote:

Specifically, I want to arrange my data in a table with rows of 6
columns. So, I have this conditional XSL statement setup to open and
close <tr>'s when appropriate.

Unfortunately, the XSL parser doesn't like the fact that within the
<xsl:when> block there is no closing tag for <tr>. (ie. Receive the
error message: "End tag 'xsl:when' does not match the start tag
'tr'.")

<code snippet>
<xsl:for-each select="course">
<xsl:choose>
<xsl:when test="position() mod 6 = 1">
<tr> <!-- PROBLEM -->
<td>
SOME DATA
</td>
</xsl:when>


Well it is (most probably) not the XSLT processor complaining but
already the XML parser used by the XSLT processor to parse your
stylesheet which is not well-formed.
You need to ensure your stylesheet is well-formed, if you want to
conditionally output something in a template then you need to put a
complete <tr> into one <xsl:when> branch.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
On 30.06.2004 16:02, John Kooistra wrote:
Hi!

I'm looking to generate an HTML table via XSL using XML data.

Specifically, I want to arrange my data in a table with rows of 6
columns. So, I have this conditional XSL statement setup to open and
close <tr>'s when appropriate.

Unfortunately, the XSL parser doesn't like the fact that within the
<xsl:when> block there is no closing tag for <tr>. (ie. Receive the
error message: "End tag 'xsl:when' does not match the start tag
'tr'.")

<code snippet>
<xsl:for-each select="course">
<xsl:choose>
<xsl:when test="position() mod 6 = 1">
<tr> <!-- PROBLEM -->
<td>
SOME DATA
</td>
</xsl:when>
<xsl:when test="position() mod 6 = 0">
<td>
SOME DATA
</td>
</tr> <!-- PROBLEM -->
</xsl:when>
<xsl:otherwise>
<td>
SOME DATA
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</code snippet>

Is there a way to tell the XSL parser that this is what I want and to
leave me alone? Or is there another (better?) way of doing this?

Thanks in advance,
John

P.S. I realize at this point that this code relies on a multiple of 6
<course> blocks in the XML to create well-formed HTML.

Hm, perhaps something of this sort could help:
<xsl:for-each select="course">
<xsl:if test="position() mod 6 = 1">
<tr>
<xsl:variable name="pos" select="position()"/>
<xsl:for-each select="../course[(position() &gt;= $pos)
and (position() &lt; ($pos + 6))]">
<td>
SOME DATA
</td>
</xsl:for-each>
</tr>
</xsl:if>
</xsl:for-each>
It isn't pretty, but is should work.

Ciao,
Igor
Jul 20 '05 #3
Igor from developersdex.com gave me this solution which worked well:

-----------------------------
Hm, perhaps something of this sort could help:
<xsl:for-each select="course">
<xsl:if test="position() mod 6 = 1">
<tr>
<xsl:variable name="pos" select="position()"/>
<xsl:for-each select="../course[(position() >= $pos)
and (position() < ($pos + 6))]">
<td>
SOME DATA
</td>
</xsl:for-each>
</tr>
</xsl:if>
</xsl:for-each>
It isn't pretty, but is should work.

Ciao,
Igor
-----------------------------
Jul 20 '05 #4
On 30.06.2004 22:12, John Kooistra wrote:
Igor from developersdex.com gave me this solution which worked well:


What? developersdex.com? I posted to comp.text.xml, in the name of
myself, to my own honour :-) I never heard of developersdex.com, I am
now interested in how I came to be connected to that lot?

Ciao,
Igor
Jul 20 '05 #5


John Kooistra wrote:
Igor from developersdex.com gave me this solution which worked well: <xsl:for-each select="course">
<xsl:if test="position() mod 6 = 1">
<tr>
<xsl:variable name="pos" select="position()"/>
<xsl:for-each select="../course[(position() >= $pos)
and (position() < ($pos + 6))]">
<td>
SOME DATA
</td>
</xsl:for-each>
</tr>
</xsl:if>
</xsl:for-each>


That is well-formed and if the XSLT does what you want then use it.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #6
> <xsl:for-each select="course">
<xsl:if test="position() mod 6 = 1">
<tr>
<xsl:variable name="pos" select="position()"/>
<xsl:for-each select="../course[(position() &gt;= $pos)
and (position() &lt; ($pos + 6))]">
<td>
SOME DATA
</td>
</xsl:for-each>
</tr>
</xsl:if>
</xsl:for-each>


another solution can be with:

<xsl:text>&lt; tr &gt; </xls:text>
--
baldo
Jul 20 '05 #7

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

Similar topics

2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
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...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
5
by: Ken Dopierala Jr. | last post by:
Hi, This is just a query about what people use most. Up until today I've been using <asp:Table> tags to build my tables. We just outsourced our HTML design to a local guy and when I got it back...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
0
by: Andy Dingley | last post by:
Background: I have a bunch of (yet unwritten) code for a JSP tag library to generate "tables" of data.The same tag library will be re-used to generate a great many "complex data view" pages. In...
3
by: PYG | last post by:
Hi everybody I have a simple question : If i use this code : <body style="font-size:24px;color:blue;"> Text in body <table> <tr><td> Text in table
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.