|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSL to create nested list items?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








