Subject: [xsl] using position() with XPath From: Michael Sobczak <msobczak@xxxxxxxxx> Date: Tue, 11 Sep 2001 06:05:23 -0700 (PDT) |
Hi, I need to use position() to get the position of an ancestor to the current <childMenu> node. Using the following xml: <?xml version="1.0" encoding="UTF-8"?> <menus> <parentMenu type="upper" title="Main Menu"> <childMenus> <childMenu title="News"/> <childMenu title="Discussions"/> </childMenus> </parentMenu> <parentMenu type="lower" title="International Menu"> <childMenus> <childMenu title="Distribution"/> <childMenu title="World Headquarters"/> </childMenus> </parentMenu> </menus> I created the the following template for the <childMenu> node: <xsl:template match="childMenu[@title]"> <LI><xsl:value-of select="position(ancestor::parentMenu)"/>_<xsl:value-of select="position()"/>. <xsl:value-of select="@title"/></LI> <xsl:apply-templates/> </xsl:template> However, both of the position() calls return the same value, like so: 1. Main Menu 1_1. News 2_2. Discussions 2. International Menu 1_1. Distribution 2_2. World Headquarters When I change the first value-of in the template to use "1 + count(parent::*/preceding-sibling::*)" as described in the FAQs, I get this: 1. Main Menu 1_1. News 1_2. Discussions 2. International Menu 1_1. Distribution 1_2. World Headquarters What do I need to do to determine the position of the current node's ancestor? Thank you for your help, - Mike. __________________________________________________ Do You Yahoo!? Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger http://im.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Suggestions to use Transf, Michael Kay | Thread | RE: [xsl] using position() with XPa, Michael Kay |
[xsl] Suggestions to use Transforme, kyyuen | Date | [xsl] resolving variables out of co, James Cummings |
Month |