[racket] sxml and variables in sxpath expressions

From: michail bulgakov (hofstadtertheman at gmail.com)
Date: Wed Sep 15 16:17:10 EDT 2010


I have almost no experience with scheme, but I started a project just to
test and play with the language.
I use lizorkins sxml library(?) to parse some xml files. However I have som
truble with the way it uses variables in sxpath.

This code works:

(define (get-title doc)
   ((sxpath "books/book[$i]/title/text()")
       (sxml:document doc)
       '[(i . 1)])))

But this dosen't:

(define (get-title doc num)
   ((sxpath ""books/book[$i]/title/text()")
       (sxml:document doc)
       '[(i . num)])))

When I debug the code I can se that i changes to num after the evaluation of
the xpath query, but I'm not sure if I use the debugger correctly since I've
only playd with it today.
What am I missing? I know that I jumped on a project thats maybe a bit to
hard for my level but I like to learn that way and it often works, but this
time I'm stuck.

Sorry for the bad english, it's not my native language and I seldom write in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100915/aa649beb/attachment.html>

Posted on the users mailing list.