[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: RE: RE: XPath question
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
|
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
|