Re: [xsl] Inverse of apply-template select

Subject: Re: [xsl] Inverse of apply-template select
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 13 Jan 2011 15:41:56 -0500
Russ,

In select="*[not(self::title)]", the subexpression "not(self::title)" is evaluated relative to each of the nodes selected by the XPath on which the predicate operates (the bracketed expression -- "filter expression" in XPath 2.0 parlance). That is, relative to whatever is selected by "*".

This is so that expressions like "p[@class='big']" (short for "child::p[attribute::class='big']") will work the way we want them to.

Another thing to keep in mind is that the logic of "*[not(self::title)]" works because there's an implicit type cast going on -- "self::title" returns a node set (either empty or not, depending on whether there are any such nodes), which becomes a Boolean true or false, which is then inverted using the Boolean function "not()".

A final note, glossing David -- you never have to say "./title" for the same reason you don't have to say "./././title".

Cheers,
Wendell

On 1/13/2011 3:19 PM, russurquhart1@xxxxxxxxxxx wrote:

That worked, thanks!


btw, why is the self:: axis needed here, but not in the previous select?

Thanks again!

Russ

Jan 13, 2011 07:59:14 PM, xsl-list@xxxxxxxxxxxxxxxxxxxxxx wrote:

On 13/01/2011 19:10, Imsieke, Gerrit, le-tex wrote:

You want to select all children who are not either bookinfo or title:



or if you are using xslt2, the more readable


select="* except (bookinfo|title)"

also, to the original poster, you never need start an xpath with ./

David



-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread