|
Subject: Re: How do I do this in dsssl/jade? From: Norman Walsh <ndw@xxxxxxxxxx> Date: Mon, 14 Dec 1998 12:54:52 -0500 |
/ "Glenn R. Kronschnabl" <grk@xxxxxxxxxxxxxxxx> was heard to say:
| I have an xml file that looks something like:
[...]
| Q1: I would like to print a phone-book like output, but I can't figure out
| how to do this in dsssl! I want something that looks like:
|
| * A *
|
| name that starts with A from <fn> tag/phone/etc
| name that starts with A from <fn> tag/phone/etc
[...]
|
| I have spent the better part of a week trying to figure this out. I have
| tried to adapt the update-dict procedure that p. prescod posted some time
| back (thread was 'List of speakers'), but no success yet. What's
| frustrating is that this would be EASY in almost any other language! Can
| someone point me in the right direction? Thanks!
|
| Q2: Right now I am sorting/reordering via perl-xml, but I assume I could
| reorder the nodelist using dsssl/jade. Anyone have some code I peruse?
|
| (Q1 is more MUCH more important)
Are you saying that all the vcards are already in sorted order? If so,
what you want's not too hard. Sorting, that would be a different kettle
of fish altogether.
Anyway, here's the sort of thing I'd do if I was starting with the
sorted list...
(define (print-vcards vcardlist)
;; print the appropriate letter heading, then print all the cards
;; that have names that start with that letter. Repeat until there
;; are no more vcards.
(let loop ((vcs vcardlist))
(if (node-list-empty? vcs)
(empty-sosofo)
(let* ((vcard (node-list-first vcs))
(fn (select-elements (children vcard) "fn"))
(letter (substring (data fn) 0 1)))
(make sequence
(print-letter letter)
(loop (print-letter-cards letter vcs)))))))
(define (print-letter-cards letter vcardlist)
;; print all the vcards that have names that start with letter,
;; then return *the rest of the list*
(let loop ((vcs vcardlist))
(if (node-list-empty? vcs)
(empty-node-list)
(let* ((vcard (node-list-first vcs))
(fn (select-elements (children vcard) "fn"))
(fnl (substring (data fn) 0 1)))
(if (equal? fnl letter)
(make sequence
(print-card vcard)
(loop (node-list-rest vcs)))
(node-list-rest vcs))))))
Or something like that.
Cheers,
norm
--
Norman Walsh <ndw@xxxxxxxxxx> | Every day is a good day.--Yun-men
http://nwalsh.com/ |
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: How do I do this in dsssl/jade?, Toby Speight | Thread | Sorting (was Re: How do I do this i, kubek |
| Re: How do I do this in dsssl/jade?, Toby Speight | Date | Re: jade translates certain things , Norman Walsh |
| Month |