K4 v6: Writing XSLTs, I’m not enjoying it

XSLT is a very powerful tool for converting an XML export from K4 into another format. The most common uses are creating archives and html versions of articles. 

I write XSLTs but I have no love of doing it. To me writing XSLTs is comparable to hitting a cement wall with your head over and over again. You feel good when finished only because the agony has stopped.

If you are going to write XSLTs yourself I can recommend a few good books. O’Reilly has good books on the subject. XSLT Cookbook is good, as is Learning XSLT and the XSLT pocket guide. Due to the sad demise of the Borders Book Store down the street I also bought XSLT by Doug Tidwell (O’Reilly) and Beginning XSLT and Xpath by Ian Williams (wrox) for 50% off. My old XSLTs don’t work so time to relearn.

No matter what type of your computer you have get the latest version of oXygen for editing and testing XSLTs. I upgraded from version 8 (2006) to the current version, 12. It is a geeky tool but it includes online reference to XSLT and has a really nice debugger. Not intended for mortals but it is the best I can recommend for this work.

K4 v6’s tools for XML export are really nice. You can have an export triggered automatically as a task. I have the task linked to a K4 XML Exporter config file (they provide a nice example) and I have that config file call the plug in file, which controls the export. Much nicer than K4 v5.8/9. The XML exporter is now part of the K4 Server package so you don’t have to install it separately, though that is still an option.

I hoped that I could do my archiving exports through an automatic action on a layout. Unfortunately the XML exported via a layout does not include the contents of attached articles. You have the option of exporting the layouts as XML and the articles as separate files, but this doesn’t solve my problem. So I am back to manually run exports that depend on premade queries. Perhaps some future version of K4 will allow me to automate the process of exporting articles connected to a layout.

The only part of the XML export is writing the XSLT transformations. K4 5.9 (and earlier) came with some really nice XSLT examples. No examples with K4 v6. *sigh*

If you are upgrading from K4 5.9 to v6 I recommend printing out some raw export xmls from 5.9 and v6 and comparing the two. Also, in upgrading your XSLTs you need to replace “http://www.softcare.de/K4Export/1.4.1” with “xmlns:k4=“http://www.vjoon.com/K4Export/2.1”. Those familiar with XSLT will think of course you dolt! Those, like me, who touch XSLTs only when necessary will not find this so obvious.

I’m making some progress and hope to finish the XSLT that I need for our web team today.