Sun Oct 5 14:14:45 CEST 2014

Mining object defs

Lot's of objects.  How to quickly get to their code?

Welcome to Racket v6.1.
racket@> (require xml)
racket@> (read-xml (open-input-file "/home/tom/git/AxoStudio/objects/filter/lp1.axo"))
racket@> (xml->xexpr (document-element (read-xml (open-input-file "/home/tom/git/AxoStudio/objects/filter/lp1.axo"))))

However, this doesn't unpack <![CDATA[ ... ]]>


(require xml)
(define f "/home/tom/git/AxoStudio/objects/filter/lp1.axo")
(define x (read-xml (open-input-file f)))
(define s (xml->xexpr (document-element x)))

Using racket path operations

(require xml/path)
(se-path*/list '(p) some-page)
(se-path*/list '(code.srate) s)
(define l (se-path*/list '(code.srate) s))
(map cdata-string l)

This is silly.  No standard way to map CDATA to string?

(define (extract-cdata data)
  (let* ([string (cdata-string data)]
         [matches (regexp-match #rx"<!\\[CDATA\\[(.*)\\]\\]>" string)])
    (list-ref matches 1)))

[1] http://stackoverflow.com/questions/2784183/what-does-cdata-in-xml-mean
[2] http://docs.racket-lang.org/xml/index.html