Re: First Occurrence of an Element

Subject: Re: First Occurrence of an Element
From: Chris Maden <crism@xxxxxxx>
Date: Tue, 14 Apr 1998 16:51:04 -0400
[Chuck Darney]
> Is it possible to know when the first occurrence of an element
> exists?  I would like to be able to affect only the first occurrence
> of say the SECTION element.

If they're always on the same level, you can use (child-number):

(= (child-number (current-node))
   1)

If they can occur at any level, you can use (element-number-list):

(= (list-ref (element-number-list '("CONTAINER"
				    "SECTION")
				  (current-node))
	     1)
   1)

(Now, try finding the first one in the container with a given
attribute name/value pair, as mandated by our house style for cross-
references.  Now *that* was fun.)

-Chris
-- 
<!NOTATION SGML.Geek PUBLIC "-//Anonymous//NOTATION SGML Geek//EN">
<!ENTITY crism PUBLIC "-//O'Reilly//NONSGML Christopher R. Maden//EN"
"<URL>http://www.oreilly.com/people/staff/crism/ <TEL>+1.617.499.7487
<USMAIL>90 Sherman Street, Cambridge, MA 02140 USA" NDATA SGML.Geek>


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


Current Thread
  • First Occurrence of an Element
    • Chuck Darney - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id QAA01565Tue, 14 Apr 1998 16:06:02 -0400 (EDT)
      • Chris Maden - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id QAA02169Tue, 14 Apr 1998 16:50:15 -0400 (EDT) <=
        • James Clark - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id AAA05683Wed, 15 Apr 1998 00:50:51 -0400 (EDT)