Talis Platform: page 2

3: Searching and display bibliographic data

[see previous page]

At this point I confess to not knowing what exactly ‘bigfoot’ is. A storage mechanism of some sort, but is it just for bibliographic style data or for anything?

Anyway, searching and displaying bibliographic records, the core of an OPAC. And no matter what ‘bigfoot’ exactly is, we are using it! In fact we are going to use the ukbib ‘store’ within Bigfoot

First some reference pages, well worth reading for all this to make sense:




Going to http://api.talis.com/stores/ukbib/items (try it now, will open new window/tab) prompts for some input (because we haven’t provided any in the url) the results look like RSS1 i.e. RDF. So any code we write must be able to pass (i.e. understand) this.

Looking at the Cenote code, it seems that it uses a neat solution, it takes the RDF data and uses an XSLT file to ‘transform’ it into a webpage.

Another option would be to use a RDF function to interpret the returned data (i.e. turn values in to normal PHP variables), we could then produce a page in a normal manner inserting the PHP variables (containing the book names etc of the search results) where we please.

I’m going to first try the first approach, using xslt template to turn the RDF/RSS in to html. In fact I’m going to take the code straight from Cenote as it is open source. :)

Searching and displaying the raw data it returns

First lets just quickly do a form that submits a search to the ukbib store and see it return some results in RDF/RSS. The form is here and sure enough we get some results back!

Cenote – understanding some of the code

Looking at the Cenote code there are a few files we are particularly interested in (copying from): searchresults.php search.fn.php and xslt.fn.php (in the includes dir).

There were a few things in the Cenote code that caused some confusion for a simple person like me.

$DataStoreHost = ‘http://api.talis.com/bf/’;
$SearchResultsOrchestrationBase = ‘http://api.talis.com/orch?profile-uri=http://schemas.talis.com/2006/orch/cnsearch&data-uri=’; $RenderItemOrchestrationBase = ‘http://api.talis.com/orch?profile-uri=http://schemas.talis.com/2006/orch/cndetail&data-uri=’;

$DataStoreUrl = “$DataStoreHost/stores/$DataStore/items?query=$query&offset=$start”;
$OrchestrationUrl = $SearchResultsOrchestrationBase . urlencode($DataStoreUrl);
$results = file_get_contents($OrchestrationUrl);
return $results;

The above code (from search.fn.php and searchconfig.php) is where the search takes place and as such is a core part of the service. It took me a minute to understand what was going on here.

What confused me is that Cenote does more than make a simple call to ukbib store. When it requests data, it does not go straight to the bigfoot/ukbib url, but to a URL starting with ‘http://api.talis.com/orch…’ , which is passed the bigfoot/ukbib URL (with the original query/search term attached) .

Now, I think this is basically because Cenote gets additional data from other sources (such as book cover thumbnails), this api.talis.com/orch service will go and get the data from the bigfoot ukbib store (as passed as a parameter to it in the URL) while using a file on a server called ‘schemas.talis.com’ which presumably tells it to do other stuff as well. If I’m right (and I may not be) it is doing something a little similar to what we find at the bottom of this page (Bigfoot – an inital tour). [Incidentally, the URL http://schemas.talis.com/2006/orch/cnsearch doesn’t seem to exist, perhaps it has been moved since they created the src bundle for download?]

Anyway, at the end of it all we have

$results = file_get_contents($OrchestrationUrl);

This is where the URL we have constructed is fired off and the data that is returned to us is stored in the var $results. When I have a go at doing this myself, I can basically ignore the ‘Orchestration’ stuff, and just fire of the search words to:


The other bit of ‘interesting’ (read: non-obvious to me) code was what comes next. Once it has the results it simply passes them to a ‘transform’ function, which can be found in xslt.fn.php. At this stage I don’t really care what it does line by line. However its end result is to take our results (data) and the location of an xslt and to produce some html formatted as per the xslt file with our data inserted in to it.

Building our own search (based on Cenote)

First things first: You can see a copy of my file here (4.php opens in new window/tab). Note: Cenote is licenced under the GNU/GPL, this is technically a derivative of Cenote so this is also licenced the same (having said this, the only code you will be interested in can already be found in Cenote!).

The aim here is not to make anything pretty, well designed or correct. Just something that works.

The file should be fairly simple:

  1. Take search string
  2. send it to Talis Platform > Bigfoot/ukbib
  3. send returned data to the ‘transform’ function to display on screen.

Let us have a look at the code (link above), again nearly all this code is from Cenote. First we check we have been passed a search string, we then call the search function (with or without a ‘start’ point, i.e. which page to start from).

The search function is different from that of Cenote. First we do not bother with the Orchestration bits. Secondly Cenote uses the file_get_contents PHP function to send the query to the Talis Platform. My web host does not allow the use of this command by default so instead I use Curl, which comes with PHP and seems to be recommend. We just fire off a request to the ukbib URL and save the results in a var.

After this, we just pass this to the Transform function, and also pass the location of the xslt file. Again a I had a bit of trouble here as originally I had errors about not knowing what ‘loadXML’ was. The PHP docs are not that helpful, but it turns out it comes with PHP5 but not PHP4. My web host allow me to change the version of PHP used on my site by the click of a button, so once I realised what the problem was it was easily resolved.

Finally, we have the xslt file. I have never edited one of these but it looks fairly straight forward. I was hoping I could just use the one from Cenote. However when I tried my newly created PHP script it produced error messages that had something to do with Amazon (I know, that’s not very technical description!). So I removed anything that mentioned Amazon (and that’s a ‘not very technical’ solution!) and you know what.

It worked! (4.html,4.php)

Let’s be clear here, bad html (no header/footer), no style sheets, the xslt refers to CSS styles that do not exist, The PHP code is badly set out, the links don’t work and it currently only searches for the first word you enter (i.e. anything before the first space). But, all those things aside, it works :)

[next page: making it work properly]

Leave a Reply