Re: (dsssl) simple loop question

Subject: Re: (dsssl) simple loop question
From: Holger Klawitter <lists@xxxxxxxxxxxx>
Date: Fri, 11 Apr 2003 08:41:24 +0200
> If "n" is the ltt-name node, then, I can do
>     (string (node-property 'char n))
> to get the character data, and
>     (equal? 'data-char (node-property 'class-name n))
> to find out if it has character data?  Or are the characters attached
> to child nodes of n?  How can entities be handled, as in
>     <ltt-name>Fran&#231;ois</ltt-name>

The simplest way is to use data, bat as you probably already observed, it 
expands entityrefs. I use the following function to avoid that.

; TODO: making it tail recursive
(define (NodeListData nl) (if (node-list-empty? nl) ""
  (string-append (let* (
            (next (node-list-first nl))
            (clz  (node-property 'class-name next))
    )
    (case clz
      ((element) (NodeListData (node-property 'content next)))
      ((data-char) (string (node-property 'char next)))
      ((sdata) (string-append "&" (node-property 'entity-name next) ";"))
      ; ideas for other branches ?
      (else (error (string-append (symbol->string clz) " unsupported!")))
    )) (NodeListData (node-list-rest nl))
  )
))

To emit Strings into sosofos, you need another function to "compile" the 
entityrefs back ;-)

Mit freundlichem Gruß / With kind regards
	Holger Klawitter
--
lists@xxxxxxxxxxxx


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

Current Thread