[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] using position() with XPath
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
|
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
|