Subject: Re: [xsl] Correcting a prior error From: Dave Pawson <davep@xxxxxxxxxxxxx> Date: Fri, 30 Jul 2010 10:44:56 +0100 |
On Fri, 30 Jul 2010 10:00:30 +0100 Michael Kay <mike@xxxxxxxxxxxx> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Correcting a prior error, Michael Kay | Thread | Re: [xsl] Correcting a prior error, Wendell Piez |
Re: [xsl] Correcting a prior error, David Carlisle | Date | Re: [xsl] Correcting a prior error, Wendell Piez |
Month |