Search

What the Quote?

"No means no, Ra."

Tim Tripcony

"Did you know that when you cook chicken in red wine it turns purple?"

Laura Tripcony

"I don't want to shoot the Pope in the eye for a Klondike bar, but anything anything else would be uncivilized."

Steven Rodgers

« Coffee tables and software development tools | Main| Props »

SnTT: Client-side XSLT with Google AJAXSLT

Category show-n-tell thursday
Over the weekend, I was playing with client-side XSLT in JavaScript, and stumbled upon a great library: AJAXSLT, from "the Google". It allows you to easily apply a stylesheet to XML data that doesn't already include a stylesheet reference. I pulled the library (which consists of 5 .js files) into a Domino database, and extended my recent barebones Ajax library to perform a transform on remote XML using XSL that is also remote. In other words, it Ajaxes the XML, then Ajaxes the XSL, does the transform, and returns the result as a string. This example (which currently works in Firefox and Safari, but not I.E. or Opera... they seem to bomb on the nested Ajax call) shows a transform result being inserted into an empty div (on an otherwise blank HTML page). UPDATE: I made the example page a bit more interactive to make it clearer what's happening, and in what sequence. A button now triggers the load, and the XML/XSL are displayed in textareas as they're retrieved.

Why bother? Well, because the largest gap I currently see in the DXL API is an inability to specify a stylesheet path in the output. I'm assuming this was omitted because we can just pipeline a NotesDXLExporter directly to a NotesXSLTransformer... except the transformer in LotusScript is... well, crap. No offense, IBM, but passing it even the most pedestrian of XSL instructions causes it to bomb. Additionally, if we're pulling a ReadViewEntries via Ajax, why send it back to the server for transforming? This approach allows us to pull the XSL from the server as well and then let the client do the work of transforming. In this example, both the XML and the XSL are Page elements; the XML Page uses an embedded view to load the data from the database. The XSL is static, but could reference URL parameters, etc., to provide dynamic transformation options, such as sorting of the data.

You can download the sample database here.

Comments

Gravatar Image1 - Sounds cool. I did almost the exact same thing a while back with the Sarissa library. I recall grabbing a RSS feed from one application and using the xsl to whip up some basic html and display the feed on a page. Sarissa was really finicky across browsers as well though.

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Contact Me

Elsewhere

Assorted Linkage


Locations of visitors to this page