Subject: ordering of output in menu rendering system From: WAGLET@xxxxxxxxxx Date: Tue, 14 Nov 2000 18:18:07 +0000 |
Hello, I'm new to XSL and need some help with ordering of output. I'm trying to describe a navigational menu and then render it according to which item is selected. The attached XML and XSL source files are quite close to what I want except for the ordering. The output I'm aiming for is: TOP MENU tit1 tit2 Pp tit23 Pp Pp tit231 Pp Pp SELECTEDtit232 tit3 <-----*** tit4 but the output I'm getting is: TOP MENU tit1 tit3 <-----*** tit2 Pp tit23 Pp Pp tit231 Pp Pp SELECTEDtit232 tit4 (note the out-of-order 'tit3' title). Can someone please explain why this is happening, and what I need to do to fix it!..... Also, on the same theme, Ideally I would like to say in one xml document: 'this page relates to the menu item x', and separately in an XSL stylesheet I would like to describe the menu and process it according to the menu that was selected in the xml source. I haven't tried this yet, but I'm presuming I can do something like compare the node string-value in the xml with the menu items and determine which matches and continue from there. If anyone would like to offer an example of how to do this I would be grateful! :) - Tushar. ------------------------------------------------------------------- <?xml version="1.0"?> <?xml-stylesheet href="t9.xsl" type="text/xsl"?> <?cocoon-process type="xslt"?> <page> <menu> <item> <title>tit1</title> </item> <item> <title>tit2</title> <item><title>tit21</title></item> <item><title>tit22</title></item> <item><title>tit23</title> <item><title>tit231</title></item> <selected-item><title>SELECTEDtit232</title> </selected-item> </item> <item><title>tit24</title> <item><title>tit241</title></item> <item><title>tit242</title></item> </item> <item><title>tit25</title></item> <item><title>tit26</title></item> </item> <item> <title>tit3</title> <item><title>tit31</title></item> <item><title>tit32</title></item> </item> <item> <title>tit4</title> <item><title>tit41</title></item> <item><title>tit42</title></item> </item> </menu> </page> ------------------------------------------------------------------- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="page"> <html><head></head><body>TOP<xsl:apply-templates/></body></html> </xsl:template> <xsl:template match="menu"> <p>MENU</p> <xsl:apply-templates select="descendant::selected-item | item[not(descendant::selected-item)]"/> </xsl:template> <xsl:template match="selected-item"> <xsl:apply-templates select="ancestor::item"/> <xsl:apply-templates select="preceding-sibling::item"/> <p><font color="red"> <xsl:call-template name="indent"> <xsl:with-param name="level" select="count(ancestor::item)"/> </xsl:call-template> <xsl:value-of select="title"/></font></p> <xsl:apply-templates select="child::item"/> <xsl:apply-templates select="following-sibling::item"/> </xsl:template> <xsl:template match="item"> <p> <xsl:call-template name="indent"> <xsl:with-param name="level" select="count(ancestor::item)"/> </xsl:call-template> <xsl:apply-templates select="title"/></p> </xsl:template> <xsl:template match="title"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="*"> X: <xsl:apply-templates/> </xsl:template> <xsl:template name="indent"> <xsl:param name="level"/> <xsl:if test="$level > 0"> Pp <xsl:call-template name="indent"> <xsl:with-param name="level" select="$level - 1"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> Best Regards, Tushar. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: copying CData sections from the, Kay Michael | Thread | Re: ordering of output in menu rend, Jeni Tennison |
Re: XSL:FO, Michael Smith | Date | RE: <xsl:import> / <xsl:include> Q, Kay Michael |
Month |