Re: Why does this work?

Subject: Re: Why does this work?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 07 Aug 2000 19:49:10 +0100
Christian,

>Now I'm glad it works, but for some peace of mind I would like to know why 
><xsl:when test="customer = preceding::row[position()=1]/customer"> 
>behaves as it does?

I'm not sure which bit you don't understand, so I'll just try to explain it
and hope that I hit the spot.

Your test returns true when the value of the child customer element of the
current node (a row) is the same as the value of the first preceding row's
child customer element.  In other words, if the customer for this row is
the same as the customer for the row before.

When you use an axis that works backwards (a 'reverse axis') like
preceding, preceding-sibling, ancestor or ancestor-or-self, then the node
list is given in reverse document order until you take the next step in the
XPath.  So, preceding::row[1] (which is exactly the same as
preceding::row[position()=1]) gets the row immediately before the current
node.

I hope this helps: let me know what's unclear if not.

Jeni

Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx


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


Current Thread