Subject: Re: using ancestorChildNumber in VBScript From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Tue, 21 Nov 2000 14:47:23 +0000 |
Todd, > As I said, that worked fine. ancestorChildNumber would back up the > tree until it got to "Holding" and return the index of that node > relative to its parent. I subtracted 1 because I wanted the index to > be zero-based. Trying to do things the new way, I can't get the > SymbolHref function to work. As Mike said, you don't need to use scripting to get this information. XPath is designed to enable you to navigate the DOM and find things out about it. You want to know the index of the current node's (the Symbol element's) parent 'Holding' element within its parent. The first Holding element should be numbered 0, the second 1 and so on. You can get this number by counting how many Holding elements occur before the one you're looking at; in other words, how many preceding siblings it has that are also Holding elements. The first Holding element won't have any preceding sibling, the second 1 and so on. To get to the parent Holding element, you can use: parent::Holding or, shorter and probably more readily optimisable: .. You can get a list of its preceding siblings using the preceding-sibling axis: ../preceding-sibling::Holding You can count nodes using the count() function: count(../preceding-sibling::Holding) So within your XSLT, you could use something like: <a> <xsl:attribute name="href"> <xsl:text>DetailScreen.asp?idx=</xsl:text> <xsl:value-of select="count(../preceding-sibling::Holding)" /> </xsl:attribute> <xsl:value-of select="." /> </a> or: <a href="DetailScreen.asp?idx={count(../preceding-sibling::Holding)}"> <xsl:value-of select="." /> </a> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: using ancestorChildNumber in VB, Kay Michael | Thread | XHTML to CALS table, Ben Skelton |
Re: adding string-length values, Zeljko Rajic | Date | Re: Copying a portion of a subtree , Jeni Tennison |
Month |