RE: searching for closest previous element

Subject: RE: searching for closest previous element
From: "Reynolds, Gregg" <greynolds@xxxxxxxxxxxxxx>
Date: Wed, 18 Mar 1998 17:14:00 -0600
You might also try using functions from the "Counting" section,
10.2.4.2, p.144.  
1.  Use (element-number-list '("Y") (current-node)) to get the number k
of Y elements in the entire grove preceding the current node.
2.  Use select-elements to gather all the Y elements in a node list Ynl.
3.  Use (node-list-ref Ynl k) to get at the desired Y element.
Haven't tested it so I don't know how fast it would be but it should do
the trick while avoiding recursive searches.
-gr
> -----Original Message-----
> From:	stephenng@xxxxxxxxxxxx [SMTP:stephenng@xxxxxxxxxxxx]
> Sent:	Wednesday, March 18, 1998 5:58 AM
	  ... 
	  
> When handling element "X", I would like to find the closest previous
> occurrence of element "Y" in the document, because I need to look up
> some attribute of element "Y".  For perverse reasons, elements "X"
> and "Y" can occur anywhere in the document, at any level, so the
> occurrence of "Y" that I need to look up would be the closest
> previous element if you flattened the whole tree.
> 
> I have a routine to do this, but it's really really slow.
	  ... 


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • Re: searching for closest previous element, (continued)
    • Norman Walsh - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id MAA00392Wed, 18 Mar 1998 12:40:40 -0500 (EST)
    • Paul Prescod - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id KAA20931Thu, 19 Mar 1998 10:32:32 -0500 (EST)
    • stephenng - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id NAA01051Wed, 18 Mar 1998 13:28:07 -0500 (EST)
      • stephenng - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id OAA17663Thu, 26 Mar 1998 14:25:03 -0500 (EST)
    • Reynolds, Gregg - from mail1.ability.netby web4.ability.net (8.8.5/8.6.12) with ESMTP id SAA04606Wed, 18 Mar 1998 18:19:21 -0500 (EST) <=