Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Wednesday, 19 January 2011

More than meets the eye

I've been working recently on a series of XSLT conversions for a big XML data set, and I'm really impressed with the stuff you can pull with that.

The job's been to take a whole load of bibliographic information from the backend of a publishing system and convert it to something which can be brought into a design package to quickly put together a catalogue. Of course, nothing is as easy as it should be, and there are a lot of little hurdles to this which - a year or so ago - would have had me running off, tail between my legs. (Actually - it *did* have me running away from the problem: I did try to write something to solve this, and entirely failed!)

But now, with a bit more thought and general XML experience, I've managed to find ways to get around all those problems, and now the biggest problem we've got is that there's a certain amount of inconsistency in the data itself. (It was all imported from some other system, and some of the data there is well over fifteen years old. And wrong.)

Generally, though, I'm amazed at the power of XSL stylesheets and what they can do to a piece of XML. Pretty much anything, really. You can even create functions within the stylesheet like any other kind of language, which is incredibly useful.

However, there are some caveats. (There always are.)

Now, as with many things, there are different versions of the stylesheet implementaton, and they come with different functionalities. Sadly, the design package in use (InDesign), will only support version 1.0. Which is a shame, because all the really cool features (the functions mentioned above, and some of the date/time function as well) only came in in version 2.

However, if you've got a bunch of data in XML format and need to repurpose it for something a little different, I'd recommend checking out the possibilities of XSLT. There are plenty of free tools available and it's not too hard to get the head round it. And it might just open up a whole new purpose to your data - or in this case, save a whole rakeload of time. And those are two very noble purposes.

Tuesday, 5 October 2010

New Project: HealthWhere

I've got another Android project on the go at the moment: HealthWhere. It's an adaptation of a utility by Russ Philips to help find local hospitals and pharmacies, using the data from OpenStreetMap.

The plan for the project as a smartphone app is to use the positioning tools available to smartphones (satellite positioning, or just approximate cellphone mast positioning) to get the user's current location, rather than just asking them to input an address. The OpenStreetMap database can then be queried, and the results returned for quick and ready reference. It should also be possible to fire those co-ordinates over into a navigation app to provide instant directions. Just add water - or something!

Plan:
The interface is roughly divided into two halves. The first half is to determine the user's location (or a location to search in, if you want), and the second is to display the results of that search in a usable and meaningful way. Of course, there needs to be a bridging part which actually gets those results, but that'll be behind the scenes.
My plan for working at the moment is to consider the app in order.
1) Determine a position to search from.
2) Carry out a search, and parse the results.
3) Display those results.
4) Give an option to upload location data if it's not there already.
I'm sure that other ideas will occur to me as I go, as well, so we'll have a (5) Other interesting stuff.

Progress:
The first stage of the app is just about complete. The opening menu screen fires up and gives the user the various search options:
  • choose between searching for hospitals or pharmacies.
  • choose a search radius
  • choose to input a location, or to use the phone's positioning features to find the current location.
From this point, the geocoding and reverse geocoding work as well, to either determine co-ordinates from the address entered, or to determine a local address from a set of co-ordinates.
The second stage is going well: the search query is constructed, and an XML file is returned which contains the results.

Next steps
The next step is to write up the classes for the different healthcare amenities, and to parse the results file into something meaningful.
Lastly, I'll be working on displaying those results as a list for the user to scroll through.
At some point, I'll also need to have a look at how to upload data as well.

Wednesday, 2 June 2010

How hard can it be? (part 2)

Answer: not all that hard - mostly!

The feed is working quite nicely, opening up an xml file saved from the feed, reading out what I want it to read out, and outputting it as pleasantly formatted HTML. Fantastic.

Now all I need to do is to figure out how to get it to read the XML file on the server itself. That's proving tricky, and I'm not sure why: the links I'm creating to the file just don't seem to work.

(Edit: as I suspected - it's because the script to get the XML file is hosted on a different server to the one that I'm trying to pull the RSS feed from, so it's a security issue. Hmm.)

(Further edit: and the webserver that I'm using doesn't like using PHP to access files not stored on that server. Trickier & tricker. One solution would be to figure out a way of caching the feed file each evening, so that I could just read from that file instead; but I'm not quite sure how to approach that. Will require further thought, apparently.)

More news later.

Tuesday, 1 June 2010

How hard can it be?

One of the things that I'd quite like to include on this proposed homepage of professional(-ish!) stuff is an RSS feed from this and possibly other blogs. Obviously, there are tools out there to make that easy (Feed2JS being one of them, and the one that I'm using at the moment).

But I quite like to know exactly what's going on under the hood in these things, so I'm going to have a quick go at putting together a home-grown version of it. How hard can it be, right? I get an XML file (the feed itself) and parse it. There have to be a thousand and five ways of doing that!

Optimism. What a fantastic feeling!