Monday, June 27, 2005

Much XSL

So I've been quiet lately. I have a whole bunch of topics to post on but I've been busy working with XSL(T) for the first time, really. Bookmarking and Furling sites; learning the ropes; picking up a few tricks, etc.

One of my main foci has been to make it easier to include lists of books.'s Associates UI for building links to products is of an exquisitely inconvenient and unpleasant character. Putting together tables of books, such as I have been doing, has involved numerous trips back and forth between the byzantine Amazon UI (so unlike their customer-oriented UIs) and a text editor for lots of search-and-replace steps, etc. It's horrifically cumbersome.

At first I thought I would use allconsuming, or its new avatar,, where I do have accounts (here and here). The old site is going away by the end of August, so I first tried adding my recent book-acquisitions there. I accidentally hit the "I have consumed this" button — which in my opinion is absurdly easy to press and needs to be made far less prominent — and found there is no UI to either UNconsume nor to delete an item you have added. I applied for and got an API key, but then discovered that the 43things API has not yet been extended to support allconsuming operations.

Ultimately in desperation I just deleted my account, hoping to recreate it. Unfortunately, something in their deletion code left what would seem to be a Zombied fragment of my old account, so I was prevented (even after waiting for several days) from recreating one with the same name, and numerous emails went unanswered ... *

Oh, well. That, plus the fact that it is not currently possible to pass one's associates ID through to allconsuming, plus the fact that I simply, and surprisingly, got bitten by two bugs: the "let's learn's Web Services API better" bug (I say "surprisingly" because I am more and more rarely bitten by this kind of bug — a hankerin' to actually do some off-hours coding — these days: I've been a professional software developer for oodles of years now so I tend to seek my hobbies in other intellectual pursuits, but I guess the tech-nerd in me still has some life yet), and then by the "let's learn XSL(T) properly this time!" bug.

Putting the two together, and throwing in the wonderful free XSLT processor Amazon provides at their site (see here), I have created a number of XSL stylesheets to convert Amazon's XML output to something pretty, for three separate applications:
  1. Replace the badge currently in my sidebar displaying a random list of books answering to the keyword "Progressive" with a badge that looks the same but displays precisely the books I want (at a future time I'll adjust it to display a random selection from precisely the books I want). I haven't installed it yet because I haven't picked the list quite yet. This is an IFrame, just like the existing badge.
  2. Use JavaScript to include a more free-form HTML table in-line with document.write() — the same technique used by most of the other places I have linked to in my sidebar. I generated such a table for inclusion in my recent Schoenhofs post, which started out with a simple list of book names (I was too tired that night to go through the unholy hell of building a list of product links from the associates site), and then changed briefly to an Allconsuming list. UNfortunately, Blogger is not cooperative about including JavaScript in posts. This thread provides a way to do it, which .. works ... kind of. But I found that it often made my blog look like a funhouse mirror: the sidebar would randomly show up inside the post, or the post would show up all wide with some of the text running vertically down the right-hand side, or whatever. No problem, however: I simply copied the generated HTML code, which was already conveniently in a single-line format (to fit in a single document.write()) from my XSL file, and pasted it directly into the post.
  3. My third XSL project has been a way to display my entire $27,000, 1500-item wishlist to display nicely on a single page. A single .. very BIG .. page. Together with sorting (very SLOW sorting) by price, title (I had to make the XSL put ", The" at the end of appropriate titles, and even by discount. This project has actually taken up most of my (off-hours coding) time in the past week, and of course this is a purely anti-social project: nobody else is going to want to see my wishlist on one giant page. For now, I accomplished putting the entire wishlist on one page by writing a simple java command-line application to pull down the raw XML for each page and piping standard out into a file (processing it through a very simple XSL sheet that stripped the Request arguments out of all but the first page) and then putting that honkin' XML file through xalan here on my laptop. I did find an intriguing posting on using recursion with Amazon to read through every page, but somehow I think's xalan processor would probably barf on a 151-page wishlist anyway. (Note also one has to use Amazon's 3.0 API or earlier, since they deliberately gelded the 4.0 API to prevent one from accessing a page higher than 14 or some ridiculous number like that; plus the wishlist search has always been broken with regards to finding out the number of pages: not only is there no way to ask, but one cannot rely on any constant behavior when one reaches the end: either the last page keeps repeating, or you get an error - though sometimes you get an error partway through and need to retry anyway). I found this sample of easy JavaScript to make one's tables sortable - it doesn't quite work and it takes over a minute to sort each column, but it's a start.

My only other change to my Blog itself was to replace the former hard-coded picture of the Tower of Babel with a nicely hacked Flickr Badge that displays a randomly-selected Babel picture from amongst the ones I uploaded and tagged with "babel". I stripped off all the surrounding schmutz from this badge (the one in my sidebar still has the schmutz) and also made it borderless; lastly I had to turn my header into a big table in order to make everything fit and format nicely. I think it's quite an improvement.

Anyway, I'll get back to posting actual content soon.

*Update 07/28/2005: Well, I was wrong. It isn't just zombie data and it probably has nothing to do with the API key. My old account really is still there:

Although I can no longer log in as jjmg or edit that profile.

The new page is at and has the imported data from the old site. Sure would be nice to be able to destroy the old one and rename my new one back to jjmg.

Categories: , , , , , , , , , , , , , , , , , ,


Track with co.mments

Post a Comment

Links to this post:

Create a Link

<< Home