- From: Swithun Crowe <swithun@swithun.servebeer.com>
- Date: Mon, 13 Feb 2006 12:22:42 +0000 (GMT)
- To: Flinton Adam <Adam.Flinton@cfh.nhs.uk>
- cc: www-forms@w3.org
Hello FA Basically what we're needing is a function which can write out an xpath FA from the current node back to the root with all attributes present FA expressed (to give us guaranteed uniqueness). Is something like: <xsl:template match="*" mode="xpath"> <!-- process parent before current node --> <xsl:apply-templates select="parent::*" mode="xpath"/> <!-- step and name of node --> <xsl:value-of select="concat('/', name())"/> <!-- position of node --> <xsl:value-of select="concat('[', count(preceding-sibling::*[name()=name(current())]) + 1, ']')"/> <!-- node attributes --> <xsl:apply-templates select="@*" mode="xpath"/> </xsl:template> <xsl:template match="@*" mode="xpath"> <xsl:variable name="apos">'</xsl:variable> <xsl:value-of select="concat('[@', name(), '=', $apos, ., $apos, ']')"/> </xsl:template> what you want? The second template isn't strictly needed if you use the count of preceding-siblings with the same name. Then again, if the attributes will give a unique path, then you don't need the position specified. Swithun.
Received on Monday, 13 February 2006 12:21:56 UTC