RE: [xsl] Generate implicit wrapper element -- details

Subject: RE: [xsl] Generate implicit wrapper element -- details
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 31 Aug 2005 13:33:47 +0100
> I worked through this example and it worked as desired. 
> However, I am having
> trouble understanding what is happening in these matches:
> 
> <xsl:template match="li[not(preceding-sibling::*[1][self::li])]"/>

Matches an li element whose first preceding sibling is not an li element.

Start from the end: self::li selects the context node if it is an li
element, or nothing if it is not.

Within [] this node-set is converted to a boolean, so the predicate
[self::li] is true if the context node is an li element.

preceding-sibling::*[1] selects the first preceding element if there is one.

So preceding-sibling::*[1][self::li] selects the first preceding element if
there is one and it is an li element.

So not(preceding-sibling::*[1][self::li]) returns true if (a) the context
item has no preceding element, or (b) the first preceding sibling element is
not an li element.

Michael Kay
http://www.saxonica.com/


> 
> <xsl:apply-templates select="following-sibling::*[1][self::li]"
>                        mode="in-list"/>
> 
> Thanks for any explanation that you can give.
> 
> Rick Quatro
> Carmen Publishing
> 585 659-8267
> www.frameexpert.com

Current Thread