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

XSL menu using multiple row HTML table

Subject: XSL menu using multiple row HTML table
From: Lea Allison <Lea.Allison@xxxxxxxxxxxxxx>
Date: Wed, 27 Feb 2002 16:26:59 +0100
xsl menu
Hello

I've have a problem that has had me up for 2 days, and I've learnt alot, but
now my head is just busting... I need help!

I am trying to create a template that will convert my XML menu doc (extract
below) into an HTML menu. The menu I wont is the horizontal type, and the
real problem I have is selecting the number of menu items per row.

I cannot figure out how to get the stylesheet to read the first X number of
items in, then start a new row, and another until complete. I cannot use
"for-each" to split the <TR> and </TR> tags without creating bad XML... and
using named templates recursively loses me when one row is complete and I
want to continue my proccessing on the newxt row.

OK, here is a snippet of the source XML:

<LIBRARY>
		<WEB>
			<HOME isCategory="yes">
				<NAME>Home</NAME>
				<DESCRIPTION>Virgin Home page</DESCRIPTION>
			</HOME>
			<VIRGININFO isCategory="yes" icon="" hide="no">
				<NAME>Virgin Info</NAME>
				<DESCRIPTION>Virgin commercial
information</DESCRIPTION>
				<CORPORATE isCategory="yes" icon=""
hide="no">
					<NAME>Corporate</NAME>
					<DESCRIPTION>Corporate
information</DESCRIPTION>
				</CORPORATE>
			</VIRGININFO>
			... ...
			<TEST>
				<NAME>LEA</NAME>
			</TEST>
		</WEB>
</LIBRARY>

I don't think this is the best way for trying to do this job, but the reason
is that I'm using XPath from my app to access these items... I'll get round
that, but here's my problem. This what I've got after 2 days deleting and
re-writing so please ignore this if it is completly wrong:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html"/>

<xsl:template match="/">

<HTML><BODY>
	<TABLE border="1" width="100%">

		<xsl:apply-templates select="LIBRARY/WEB" />

	</TABLE>
</BODY>
</HTML>

</xsl:template>

<xsl:template match="LIBRARY/WEB">

<xsl:param name="max">8</xsl:param> <!-- MAX ITEMS PER TABLE ROW -->

	<TR>
	<xsl:for-each select="*">
		<xsl:choose>
		<xsl:when test="position() -1 &lt; $max">

			<xsl:apply-templates select="NAME" />
			
		</xsl:when>
		</xsl:choose>
	</xsl:for-each>
	</TR>
			<!-- xsl:apply-templates select="//LIBRARY/WEB" /
--> <!-- !!!! err ? -->
</xsl:template>

<xsl:template match="NAME">
	<TD><B><xsl:apply-templates /></B></TD>
</xsl:template>

<xsl:template match="*" />
</xsl:stylesheet>


Cheers!!

Lea

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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