Archive for the ‘Web’ category

Pesterfish

August 28, 2008

In my research for what data serialisation models to use to represent our repository data, I was hunting down some XML to JSON conversions. For the past few months I have been hell-bent on using JSON as the representations, because it is far more useful to me than chunks of XML, and closer to the nature of the data being represented. As Steve Yegge says:
“XML is better if you have more text and fewer tags. And JSON is better if you have more tags and less text”.

The problem is however that almost all the tools out there in Fedora-Commons land are biased towards XML, and have (almost) never heard of JSON. So if I only have some basic Dublic Core and a gob of JSON in my objects, that is not going to help very much. The other extreme, and undoubtedly “The Right Way To Do It” is to have a lovely shiny Content Model and define everything in an ontology and RDF and then my brain melts. And we want to migrate our repository sooner rather than later and don’t have the time to remain in la-la land designing around our navels forever.

So now I am swinging back the other way and have decided to store the data in the objects as simple stupid XML with a smattering of tags, and at least have some XSLT disseminators to provide more buzzword compliant FOAF, Bibliontology, OAI-ORE etc. And JSON. Via XSLT. Which brings me to http://code.google.com/p/xml2json-xslt/ which pointed at http://badgerfish.ning.com/ and finally to pesterfish:

Jacob Smullyan wrote a related Python model, pesterfish, which he describes as: “a quick Python module which is uses the same xml object model as the dominant xml module in the Python world, elementtree; Some elementtree implementation (there are several) and simplejson are required. BTW, elementtree stores namespaces in Clark notation: {http://www.w3.org/1999/xhtml}br and so does this.”. pesterfish also lets you round trip XML through it without any data loss.

I like the ElementTree API. Lots. It is very elegant and a joy to work with, especially if you have ever had to use any other XML APIs like DOM or SAX that makes you want to gnaw your own arm to the bone out of frustration. So the chance of having an ElementTree-like way of consuming XML in Javascript expecially appeals to me. (well until http://en.wikipedia.org/wiki/E4X E4X is widely supported)

And so, with this long-winded preamble I would like to present pesterfish on AppEngine:

http://epoz.appspot.com/pesterfish/

You can POST an XML file to it, and it will return the pesterfish application/json.

Or you can call it with a URL for the XML file specified in the ‘in=’ parameter, like this.

http://epoz.appspot.com/pesterfish/?in=http://www.w3schools.com/XML/note.xml

It turns this XML:

<note>

	<to>Tove</to>

	<from>Jani</from>

	<heading>Reminder</heading>

	<body>Don't forget me this weekend!</body>

</note>

Into this JSON:

{"text": "\n\t", "tag": "note", "children":
 [{"text": "Tove", "tail": "\n\t", "tag": "to"},
 {"text": "Jani", "tail": "\n\t", "tag": "from"},
 {"text": "Reminder", "tail": "\n\t", "tag": "heading"},
 {"text": "Don't forget me this weekend!
", "tail": "\n", "tag": "body"}]}

And it supports JSONP:

http://epoz.appspot.com/pesterfish/?in=http://www.w3schools.com/XML/note.xml&callback=some_callback

Thanks Jacob!

Problems with OS X Leopard, Apache and symbolic links

March 19, 2008

I just can’t get symbolic links in the ~/Sites/ folder to some working files in the ~/Documents/ folder  working under Apache. The error message in the log file is: “Symbolic link not allowed or link target not accessible”It has been bugging me since after dinner, and it is now 3o minutes into the witching hour, and man, is it starting to piss me off.I have slogged through all the options for enabling FollowSymLinks in the various *conf files, and ensuring it isn’t a ‘Allow from all’ missing somewhere. There is deeper mojo at work, and I suspect some kind of default users/permissions security setting. But what?If this was Ubuntu I would have been happily working for hours in stead of fighting the system. Grumble, grumble. But then the power supply on my Linux box blows up. Grumble. Grumble. At least I am not the only one with the problem, here, here and here are posts that I found with a similar issue. The ACL thing has however not helped me, removing all ACLs in site did not make a difference to me. So I am still without a solution. Bugger.Oh Lazyweb I beseech thee, come to my rescue!