[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Correcting a prior error

Subject: Re: Correcting a prior error
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Fri, 30 Jul 2010 10:44:56 +0100
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="."/>

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.



Dave Pawson

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.