Re: [xsl] 1st previous node()

Subject: Re: [xsl] 1st previous node()
From: "Christopher R. Maden" <crism@xxxxxxxxx>
Date: Tue, 08 Feb 2011 09:24:47 -0500
On 02/08/2011 01:16 AM, Karl Stubsjoen wrote:
> Given that <X> is the context node then I expect the previous node is
> <B>.
>
> <A>
>  <B>
>   <X> this is context node </X>
>  </B>
> </A>

This suggests to me that you are thinking about *tags*, not *nodes*.

B is the ancestor of X, not its predecessor.

This paragraph from XPath 1.0 may help:

> NOTE: The ancestor, descendant, following, preceding and self axes
> partition a document (ignoring attribute and namespace nodes): they
> do not overlap and together they contain all the nodes in the
> document.

Others have already pointed out the usefulness of * over node() in your
examples, and the possible utility of the preceding-sibling axis.  I
recommend re-reading <URL: http://www.w3.org/TR/xpath/#axes >, or the
more precise but harder to read <URL: http://www.w3.org/TR/xpath20/#axes >.

~Chris
--
Chris Maden, text nerd  <URL: http://crism.maden.org/ >
bFor a successful technology, reality must take precedence over
 public relations, for Nature cannot be fooled.b b R.P. Feynman
GnuPG Fingerprint: C6E4 E2A9 C9F8 71AC 9724 CAA3 19F8 6677 0077 C319

Current Thread