This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Position of parent node


Hi Athanasios ,

> Inside the <xsl:template match="b">
> I would like to do the following check:
>
> If the position of <p> within <q> is the last one
>   do thing with <b>
> else
>   do other with <b>

Your question is not sufficiently specific -- "the position of <p> within
<q>" -- but relative to which nodelist??? Will you count only the <p> nodes?
Or maybe you'll count also other siblings of "p" (e.g. text nodes)?

In the two situations above the values for "position" will be different!

I'm assuming that your case is the first and you're counting only the "p"
children of q.

Then the XPath expression that will return the value of the "position" of a
"p" node among its siblings (assuming your current node is a grandchild of a
"p") is:

count(..\..\preceding-sibling::p) + 1

Hope this helped.

Cheers,
Dimitre Novatchev.



__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]