Re: element in mixed content

Subject: Re: element in mixed content
From: Chris Maden <crism@xxxxxxx>
Date: Fri, 3 Apr 1998 13:11:26 -0500
[Page Pressa]
> I'm trying to find the location of an element when it is within
> mixed content. I want to know if there is data occurring after the
> inline element and to get that string.
> 
> For instance,
> 
> <p>blah blah blah<mark>blah blah blah</p>
>                        ^            ^
>                        |____________|
>                               |
>                             gimme
> 
> where Mark is EMPTY.

This is kind of gross, but it's the best I can come up with right now:

Assume that the <mark> element has been located, and assigned to
mark-element.

(let get-next-data ((this-node mark-element)
		    (next-node (fsibling mark-element)))
     (if (node-list-empty? next-node)
	 ""
	 (let ((next-char (char next-node)))
	   (if next-char
	       (string-append next-char
			      (get-next-data next-node
					     (fsibling next-node)))
	       ""))))

This will skip over any other empty elements, child elements,
processing instructions, and entities, but grab all of the direct
characters until the end of the element.  It assumes the following two
procedures:

;; (fsibling snl) returns the immediately following sibling of a node.
(define (fsibling snl)
  (node-list-first (follow snl)))

;; (char snl) returns the character of a node if any, or #f.
(define (char snl)
  (node-property 'char
		 snl
		 default: #f))

This is mostly untested; use at your own risk.

-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
  • element in mixed content
    • Page Pressa - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id MAA05188Fri, 3 Apr 1998 12:32:29 -0500 (EST)
      • Chris Maden - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id NAA06526Fri, 3 Apr 1998 13:09:26 -0500 (EST) <=
        • Chris Maden - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id NAA06876Fri, 3 Apr 1998 13:20:24 -0500 (EST)