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

RE: XSL to create nested list items?

Subject: RE: XSL to create nested list items?
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Fri, 19 Nov 2004 13:27:27 +0200
nested list java
Hi,

> I tried your template sample, but kept getting errors on the first
> xsl:template line.

Was the xsl:template the first element in the file? You have to use
xsl:stylesheet as the root element, I just omitted it for brevity.

> That's PHP for you though, it's VERY
> picky I'm finding,
> and I don't see anything in the line that would trigger an error.
>
> I did manage to resolve the problem though.  I took my clue
> from your "menu"
> template, and kicked myself for not seeing the simpler way
> sooner.  Instead
> of simply putting a new <item> element inside an existing
> one, I wrapped the
> sub-menu items in a <menu> element.  Then, with the XSL, I
> could write a
> template for the <menu> elements that would create the <ul>
> tags... er,
> here's the new xsl - I think it's easier to see what I did
> than me trying to
> explain it:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> 	<xsl:template match="/">
> 		<xsl:apply-templates/>
> 	</xsl:template>
>
> 	<xsl:template match="menu">
> 		<ul>
> 			<xsl:apply-templates/>
> 		</ul>
> 	</xsl:template>
>
> 	<xsl:template match="item">
> 		<li>
> 			<a href="{url}">
> 				<xsl:value-of select="name"/>
> 			</a>
> 		</li>
> 		<xsl:apply-templates select="menu"/>

This xsl:apply-templates should be inside the above li element, right after
the a element. That way you get valid XHTML.

Cheers,

Jarno

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.