Pattern matching question for Swindle



Hi,

I'm using PLT scheme with Swindle and SSAX (latest version of everything) to write a simple program which locates and plays songs using the iTunes Music Library XML file. Why don't I use iTunes? Because I'm doing this on Linux. It's all fairly straightforward until I get down to handling the XML file itself.

The library file is huge -- in excess of 140MB on disk, and storing the entire XML file in memory as SXML is undesirable, as I want to be able to run more than one program in memory on my tiny little server. For the same reason, I'd also like to do only one pass on the data.

To get to the point, my approach has been to, at the element-finish stage, to match against a partial SXML and rewrite it. I will have something very like this structure in the "seed" parameter in the FINISH-LEVEL handler:

'(dict
(key "38")
(dict
(key "Track ID")
(integer "38")
(key "Track Number")
(integer 1)
(key "Name")
(string "Rhapsody in Blue")
(key "Artist")
(string "Andre Previn")
(key "Composer")
(string "George Gershwin")
(key "Genre")
(string "Classical")))

I may have more or fewer "key" elements, but there will be only one (or integer string data float true false) elements after each key. What I've wanted to do is this:

(let/match
('dict
('key *)
('dict items := ...))
seed
(let ((track (make-track)))
; create the track from items and put it on the end of the seed )


To create a structure that looks like:

(dict
<struct:track>
...)

That let/match, of course, doesn't work. Can anyone tell me what I'm doing wrong? Is there a "better" pattern matcher for PLT-Scheme or a better solution to this problem I'm missing? Swindle looks like a wonderful library, but I'm at a loss sometimes on how to use it.

I guess a good answer would generalize, too. What is the best way to pattern-match on a deeply nested list?


- Jeff
.



Relevant Pages

  • Re: Help With PyParsing of output from win32pdhutil.ShowAllProcesses()
    ... None to a string). ... Still have an urge to parse with pyparsing? ... pyparsing Dict class. ... keys from the parsed data, so it looks like you are already thinking ...
    (comp.lang.python)
  • Re: Python Module: nift
    ... Replace many-branched if-elif with dict ... Now you can implement leet() using access to the LEET_LETTERS ... for letter in string: ... could just list the two strings of key and value characters, ...
    (comp.lang.python)
  • Re: Read XML file using OOP
    ... // Open the XML file that has the XML text. ... string make = gcnew String carNode->Attributes ... private int _milage; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SAX - is there an equivalent to the DOM .nodeTypedValue for reading the whole node data at o
    ... SAX. ... decode this data and generate the appropriate images onto disk. ... Private Sub IVBSAXContentHandler_characters(text As String) ... The XML file will contain 100s of images, ...
    (comp.text.xml)
  • Re: XML JDOM
    ... I have some problem in one of my xml file which value "&" in it. ... String content_id = attribute.getValue; ... // get all root child elements ... for (Iterator iter = allChildren.iterator(); ...
    (comp.lang.java.programmer)