Re: [xsl] the nearest ancestor with the attribute

Subject: Re: [xsl] the nearest ancestor with the attribute
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 15 Jan 2001 17:19:08 +0000
Hello Guai,

  gets you the ancestors with the 'attr' attribute, from nearest to furthest

  gets you the first of these

  gets you the attribute nodes themselves (from nearest to furthest)
  this is often good enough, because if (for example), you ask for the
  value of this node set, you'll get the value of the first one (the nearest)

  gets you the same set, only excluding all attributes from the list
  that have no value or a whitespace-only value

the trick is, however, that
  won't get the nearest attr attribute, but the whole set
  this is because [position()=1] will test true for any attribute
  (won't it?)

if you want to filter the nodes so only the attribute on the nearest ancestor
with the attribute is returned, you have to do


This takes the node set of all the attr attributes on all ancestors, groups them in document order, and takes the last in the list. This will be the nearest.

Hope that helps!

At 01:45 PM 1/15/01 -0800, you wrote:
How could I get the nearest ancestor with a certain attribute, say "attr"?


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 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 ======================================================================

XSL-List info and archive:

Current Thread