Amazon Web Services in Scheme

Initial screen for Amazon Web Services (AWS) in Scheme
Earlier, I showed my Programming Languages class how XML and s-expressions were related and how to use the SSAX parser to parse XML into s-expressions. I wanted to do something more real, however, so yesterday, I wrote a package to call Amazon Web Services from Scheme, parse the results using SSAX, and query the output using SXPATH. The result was a s-expression version of the results formatted as HTML.

That's not nearly enough, however since after you've run the query from inside the Scheme interpreter a couple of times and see the results come back, you want a Web page. So, I used the Web server that comes with DrScheme to write a Scheme servlet that uses the AWS query code to build a Web application that lets a user query Amazon and see the formatted results. I've put together a page to describe how I did it.

Results of querying AWS for "eagles" in books.

The pictures at the right show the Web application in action and the code is available for downloading in the pages linked above.

I've written programs that use XML in Java, Perl, Python, XSLT, and now Scheme. Scheme has been the easiest. I think the reason is that with s-expressions, XML is essentially a native data type in Scheme. That's an incredibly powerful idea. Your milage, of course, may vary. If Lisp isn't your thing, you'll have to wait for something else.

My primary purpose in doing all of this is to show my students why understanding programming language concepts and how to build language interpreters is relevant. Using XML is all about defining data languages, including BNF (schema) and then parsing and manipulating the results. The point isn't that this is in Scheme, but that once they know how to do it in Scheme, doing it in another language will be just adapting what they already know.