Just seen Tony Hirst's @psychemedia blog item about Treemapping the party make-up of council committees. Tony has done inspiring work with various public datasets, using a mixture of Yahoo Pipes, Google Documents and PHP. This latest work uses data from OpenLocally developed by Chris Taggart @CountCulture
I hadn't seen this site before. The content and presentation are great and I've yet to see such a program friendly site. Not only is the data available as json and XML, but the URLs are programmer friendly too: The HTML URL http://openlylocal.com/councils/149-Bristol-City-Council has an alias of http://openlylocal.com/councils/149.
>I set about mimicing Tony's exercise using XML and XQuery/XSLT. The XML version of a page has a .xml suffix, so the XML version of the main page for Bristol is http://openlylocal.com/councils/149.xml. ; For each committee, the XML URL is based on the committee id e.g. the Full Council Meeting is http://openlylocal.com/committees/2575.xml.
>I decided on a simple tablular visualisation to start with. (I must say I find Tree Maps rather confusing). Here is the unadorned page for Bristol City: http://www.cems.uwe.ac.uk/xmlwiki/Councils/committeeParties.xq?id=149
The script transforms the main page and all the committee pages into an intermediate XML structure, so that all parties can be extracted and assigned a color. This intermediate XML is then transformed to HTML. The script is XQuery but could be two XSLT scripts in a pipeline except that doc() is failing in XSLT just now on my server.
This is the first step:
let $id := request:get-parameter("id","") let $councilURL := concat("http://openlylocal.com/councils/",$id,".xml") let $council := doc ($councilURL )/council let $extract := element council { $council/name, for $committee in $council/committees/committee return element committee { $committee/title, $committee/id, let $committeeURL := concat("http://openlylocal.com/committees/",$committee/id,".xml") for $member in doc($committeeURL)/committee/members/member return element member { attribute name {concat($member/first-name," ",$member/last-name)}, attribute party {$member/party} } } }
The next step extracts all the Parties and assigns them a colour - known parties from a configuration table, unknown ones a random color. Finally the committees are ordered by size and output as a table, using the style attribute of a div to generate the bar charts.
Thanks to Chris for making me feel welcome on his site - a rare experience. Next task to generate KML from the index page - what great little teaching examples, especially when I can fix XSLT. I'm becoming a bigger fan of XSLT every day.