On Fri, 30 Jul 2010 10:00:30 +0100
Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:
I think you're out by one: the outermost element will have
count(ancestor::*|preceding::*)
equal to 0, but can be retrieved as (.//*)[1].
Because I'm counting preceding|ancester, which ignores self!
That's what I missed.
I think I would use
<xsl:key name="p" match="*">
<xsl:number level="any" count="*" from="/"/>
</xsl:key>
then
<xsl:variable name="posn">
<xsl:number level="any" count="*" from="/"/>
</xsl:variable>
<xsl:variable name="val" select="document($src)/key('p', $posn)"/>
Michael Kay
Saxonica
Checking my understanding:
Key of *all* elements..... I can see what it
posn variable, inside my template matching a element,
Holds up to, and including current context node.
val then retrieves .... should be the element value? That I don't
understand Mike? My template matches on the element, not the attribute?
I use $val as the @href value
<!-- Now copy this across -->
<x:a href="{$val}">
<xsl:value-of select="."/>
</x:a>
Tried it. It works, I'd like to understand why?
<-this is an attempt to select the 'right' a element->
<xsl:variable name="posn"
select="count(ancestor::*|preceding::*)"/>
Or change this to count(ancestor::*|preceding::*) + 1?
That also works.
--
regards
--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--