[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Correcting a prior error
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
|
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
|