getting the attributes of a tag to qualify rewrites
Terrence Brannon <[email protected]> Tue, 13 Jul 2004 10:23:57 -0400
| Newsgroups | gmane.lisp.scheme.ssax-sxml |
|---|---|
| Message-ID | <[email protected]> |
I have the following rule:
(define (xform-person-name name-string)
`(span *preorder* . ,(lambda (tag . content)
'(span ,name-string))))
But I need to make it more precise. I only want to rewrite span tags if
the span tag has an attribute named "hsi" with value "overwrite_name", eg:
Hello there,
<span hsi=overwrite_name>blah blah</span>
did you know that today was
<span hsi=todays_date>blah blah blah</span>
?
Converting this to SXML is a snap with htmlprag:
(define (file->sxml file)
(html->sxml (open-input-file file)))
(*TOP* (*DECL* DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN") "\n" (html "\n" " " (head "\n" " " (title "Point
Mutation") "\n" " ") "\n" "\n" " " (body "\n" " " (h1 "Point
Mutation") "\n" "\n" "\n" " Hello there,\n" " " (span (@ (hsi
"overwrite_name")) "blah blah") "\n" " did you know that today was\n"
" " (span (@ (hsi "todays_date")) "blah blah blah") "\n" " ?\n"
"\n" "\n" " " (hr) "\n" " " (address (a (@ (href
"mailto:[email protected]")) "U-MOKSHA\\metaperl")) "\n" (*COMMENT* "
Created: Tue Jul 13 07:44:29 EDT 2004 ") "\n" (*COMMENT* " hhmts start
") "\n" "Last modified: Tue Jul 13 07:47:44 EDT 2004\n" (*COMMENT* "
hhmts end ") "\n" " ") "\n") "\n")
I am trying to do HTML templating in the style of the Java framework
called XMLC (xmlc.enhyrdra.net). I have implemented such templating for
Perl via my HTML::Seamstress module, but now I want to use Scheme and
need a little help getting the same things done under ssax/sxml.
Sorry for the chatty post, but just wanted to give a little background :)
--
(let recur ((lis x) (k k))
(if (zero? k) (values '() lis)
(receive (prefix suffix) (recur (cdr lis) (- k 1))
(values (cons (car lis) prefix) suffix)))))
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com