RE: String problem

Subject: RE: String problem
From: "Maltby, David G" <david.g.maltby@xxxxxxxx>
Date: Wed, 08 Mar 2000 10:36:32 -0500
Sorry Mark this won't work as written:
> (element INDEX-ENTRY
>  (let ((term-list (match-split (attribute-string (normalize 
> "term")) ";"))
>   (let loop ((t-list term-list))
>    (cond
>     ((null? t-list)
>       (empty-sosofo)
>     )
>     (else
>      (sosofo-append
>       (make element gi: "index-entry"
>        (let ((name-value-list (match-split (car t-list) ":")))
>         (sosofo-append
>          (make element gi: "indexprimary"
>           (literal (car name-value-list))
>          )
>          (make element gi: "indexsub"
>           (literal (cdr name-value-list))
>          ))))
>       (loop (cdr t-list))))))))

I forgot that (match-split) returns in the list the delimiter also.  That
is, for your term="No Content documents:description; Content: no
description", splitting on ";" will return:
("No Content documents:description" ";" "Content: no description")  
and in the same way splitting the name-value pairs would return:
("No Content documents" ":" "description")
("Content" ":" "no description")

The above procedure does not take the delimiter into account.  Try this

(element INDEX-ENTRY
 (let ((term-list (match-split (attribute-string (normalize "term")) ";"))
  (let loop ((t-list term-list))
    ((or (null? t-list) (string=? (car t-list) ";"))	;not sure: if null?
is #t 
      (empty-sosofo)                                   ;then string=?
      (make element gi: "index-entry"
       (let ((name-value-list (match-split (car t-list) ":")))
        ;TODO: add error checking on return before processing
         (make element gi: "indexprimary"
          (literal (car name-value-list))   ;first atom in list
         (make element gi: "indexsub"
          (literal (cddr name-value-list))  ;third atom, second atom is
      (loop (cdr t-list)))))))) 

"nothing like making your foibles public" dm

 DSSSList info and archive:

Current Thread