Subject: RE: RE: RE: [xsl] XPath question From: cknell@xxxxxxxxxx Date: Tue, 04 Feb 2003 13:49:37 -0500 |
The solution: (the normalize-space() function is only here because my processor is defective) =================================================== <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" encoding="UTF-8" /> <xsl:strip-space elements="*" /> <xsl:template match="/"> <div id="menu-tree"> <xsl:apply-templates mode="main-menu" /> </div> <xsl:apply-templates mode="sub-menu" /> </xsl:template> <xsl:template match="menu" mode="main-menu"> <div id="menu"> <xsl:apply-templates mode="main-menu" /> </div> </xsl:template> <xsl:template match="item" mode="main-menu"> <xsl:variable name="id"><xsl:number level="multiple" format=".01." /></xsl:variable> <xsl:choose> <xsl:when test="@title"><div id="m{substring(normalize-space($id), 1, string-length(normalize-space($id)) -1)}"><xsl:value-of select="@title" /></div></xsl:when> <xsl:otherwise><div id="m{substring(normalize-space($id), 1, string-length(normalize-space($id)) -1)}"><xsl:value-of select="." /></div></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="item[item]" mode="sub-menu"> <xsl:variable name="id"><xsl:number level="multiple" format=".01." /></xsl:variable> <div id="s{substring(normalize-space($id), 1, string-length(normalize-space($id)) -1)}"> <xsl:apply-templates mode="menu-item"/> </div> <xsl:apply-templates mode="sub-menu"/> </xsl:template> <xsl:template match="item" mode="menu-item"> <xsl:variable name="id"><xsl:number level="multiple" format=".01." /></xsl:variable> <xsl:choose> <xsl:when test="@title"><div id="m{substring(normalize-space($id), 1, string-length(normalize-space($id)) -1)}"><xsl:value-of select="@title" /></div></xsl:when> <xsl:otherwise><div id="m{substring(normalize-space($id), 1, string-length(normalize-space($id)) -1)}"><xsl:value-of select="." /></div></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="item[not(item)]" mode="sub-menu" /> </xsl:stylesheet> -- Charles Knell cknell@xxxxxxxxxx - email XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Determining the type of a, David Carlisle | Thread | [xsl] <textarea>, HTML and CDATA, Anode |
Re: [xsl] is XSLT 2.0 implementable, Tobias Reif | Date | RE: [xsl] is XSLT 2.0 implementable, bryan |
Month |