Kiln development: convenience features

Until recently, Kiln has felt to me like a bare bones developer’s tool, providing a simple but powerful framework for doing whatever XML publishing you might want, without any hand holding beyond some common elements added on to Cocoon. That has changed, somewhat, to the extent that now a new user, completely unfamiliar with XSLT, is guided in a new project to a site displaying TEI as HTML, complete with faceted search, without touching any code.

This, coupled with the new tutorial, hopefully makes Kiln a much more attractive proposition to those who are not so technically inclined (or who have not been forced to use and learn it by working at DDH!). Now I’ve gone back to adding in elements that aid the developer, and I’ll describe three of those.

The first is a couple of functions for handling query string parameters (when one is using {request:querystring} rather than the request generator, which provides XML). While XSLT 2.0 makes string manipulation hugely more convenient than in XSLT 1.0, it’s still a bit tedious to take a Solr search string with facets and create a new query string that has one facet removed. Enter the kiln:query-string-from-string function, which is passed a query string, a sequence of parameter names to modify, and a sequence of the new values for those parameters, and returns a new query string. A parameter is removed simply by passing in an empty string as the parameter value. The other function is kiln:query-string-from-sequence, which does the same thing but is passed a sequence of parameters as the first argument.

The second takes advantage of the fact that Cocoon’s sitemaps (that define the URL space and views for a site)  are XML, and are thus prime targets for being the source documents for a Cocoon map:match. When a map:match calls out to multiple other URLs, which in turn reference other URLs, tracking down the paths across multiple sitemap files, and then looking into XSLT files which have their own imports and includes, can be time consuming and difficult to keep track of. Kiln’s admin now provides an extremely handy way of seeing just what the full pipeline is for a given URL, with all internal URL references expanded and with links to an XSLT view that includes all imported and included XSLT. This is available under the Introspection menu item.

This was a really fun feature to implement, assembling all of the sitemap files into one document and annotating it with the information required so that wildcard matching and so forth was all handled correctly. The output is perhaps not as nice as it might be (there is a fair bit of information available as tooltips when hovering over different parts of the XML representation, which is not immediately obvious), but it’s still a beautiful example of what can be done in the system.

Building on that annotated super-sitemap, I also added a reverse URL resolver. This allows for an XSLT to create a link to a resource within Kiln based solely on the @id of the map:match, passing in the wildcard parameters it requires. This decouples the actual URL from the map:match, and means that if the @pattern is changed, the XSLT creating links to that map:match don’t need to be changed — or, if the wildcards are changed, it is at least easy to find those XSLT that need to be updated, by searching for the @id.

Hopefully others find these features as useful as I already have! If anyone has suggestions for other improvements to Kiln, I would love to hear them.

Leave a Reply

Your email address will not be published. Required fields are marked *