|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: extract xpath locator
Hello, I have written a recursive template to extract the XPath pointing to an element <xsl:template name="getPath"> <xsl:param name="node"></xsl:param> <xsl:if test="$node"> <xsl:call-template name="getPath"> <xsl:with-param name="node" select="$node/parent::*"></xsl:with-param> </xsl:call-template> <xsl:text>/</xsl:text> <xsl:variable name="name"> <xsl:value-of select="name($node)"></xsl:value-of> </xsl:variable> <xsl:value-of select="$name"></xsl:value-of> </xsl:if> </xsl:template> This gives the hierarchy. Eg, applied on <b> in: <doc>This is <i><b>a</b></i> test</doc> it outputs "/doc/i" But I cannot figure out how to compute the positions of nodes; applied on <b> in: <doc>This <i>i</i>s <i><b>a</b></i> test</doc> of course, it still outputs "/doc/i", but I want to improve it to output "/doc/i[2]". Since the context node is the <b> element, using 'position()' in the template returns its position(). I cannot tell the template that $node becomes the context node --maybe it's possible, but I don't know how. I have tried to "count(preceding-sibling::$name)", but saxon does not like it. I keep trying harder. Thanks in advance for your help. N. Mazziotta
|
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
|

Cart








