[racket] sxml and variables in sxpath expressions

From: YC (yinso.chen at gmail.com)
Date: Wed Sep 15 16:22:55 EDT 2010

Use quai-quote and unquote to use variables within a list.

`((i . ,num))

instead of

'((i . num))

Cheers,
yc


On Wed, Sep 15, 2010 at 1:17 PM, michail bulgakov <
hofstadtertheman at gmail.com> wrote:

> Hi!
>
> 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)
>   (srl:sxml->xml
>    ((sxpath "books/book[$i]/title/text()")
>        (sxml:document doc)
>        '[(i . 1)])))
>
> But this dosen't:
>
> (define (get-title doc num)
>   (srl:sxml->xml
>    ((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 it.
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100915/ae570424/attachment.html>

Posted on the users mailing list.