[racket] se-path* returning multiple strings when tag contains XML entities

From: Giacomo Ritucci (giacomo.ritucci at gmail.com)
Date: Sun Dec 1 10:36:22 EST 2013

Hi Racket Users,

I'm using se-path*/list to extract values from an XML collection but I
found a strange behaviour when the extracted values contain entities.

For example, given the following XML:

<bands>
    <name>Derek & the Dominos</name>
    <name>Nick Cave & the Bad Seeds</name>
</bands>

when I extract a list of band names with (se-path*/list '(name) xe) I'd
expect this result:

    '("Derek & the Dominos" "Nick Cave & the Bad Seeds")

but what I actually receive is:

    '("Derek " "&" " the Dominos" "Nick Cave " "&" " the Bad Seeds")

Is this the intended behaviour? How can I overcome this and make
se-path*/list return one string for tag?

Here's my test code, I'm running Racket v5.3.6 on Linux x86_64 and maybe
I'm doing overlooking something because I'm new to Racket.

Thank you in advance!

Best regards,
Giacomo

#lang racket

(require xml
         xml/path)

(define xe (string->xexpr "<bands><name>Derek & the
Dominos</name><name>Nick Cave & the Bad Seeds</name></bands>"))

(module+ test
  (require rackunit)

  ;; what I get
  (check-equal? (se-path*/list '(name) xe)
                '("Derek " "&" " the Dominos" "Nick Cave " "&" " the Bad
Seeds"))

  ;; what I'd expect
  (check-equal? (se-path*/list '(name) xe)
                '("Derek & the Dominos" "Nick Cave & the Bad Seeds")))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131201/aeaf4a5e/attachment.html>

Posted on the users mailing list.