<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>XSL · Grey Nicholson</title><id>https://gkn.me.uk/entries/xsl</id><link href="https://gkn.me.uk/entries/xsl" rel="alternate"/><link href="https://gkn.me.uk/entries/xsl/feed" rel="self"/><author><name>Grey Nicholson</name></author><icon>https://gkn.me.uk/style/icon.svg</icon><updated>2025-10-21T12:11:00+00:00</updated>
<entry><title>The Twaddlebot has been unleashed</title><id>https://gkn.me.uk/weblog035</id><link href="https://gkn.me.uk/weblog035" rel="alternate" type="text/html"/><published>2004-06-07T18:40:00+00:00</published><updated>2004-06-07T18:40:00+00:00</updated><content type="html">
&lt;p&gt;
Last night version 1.0 of &lt;a href=&quot;/thetwaddle&quot;&gt;The Twaddle&lt;/a&gt; went live. It uses arbitrary &lt;abbr title=&quot;Extensible Markup Language&quot;&gt;XML&lt;/abbr&gt; and &lt;abbr title=&quot;Extensible Stylesheet Language Transformations&quot;&gt;XSLT&lt;/abbr&gt; to generate valid &lt;abbr title=&quot;Extensible Hypertext Markup Language&quot;&gt;XHTML&lt;/abbr&gt; pages... offline.
&lt;/p&gt;
&lt;p&gt;
The idea of uploading bare-bones articles and an XSLT template, allowing the browser to generate pages as they&#x27;re required, was &lt;a href=&quot;/weblog028&quot;&gt;a no-go&lt;/a&gt;. But I managed to rig up the transformation offline, to be run as a batch.
&lt;/p&gt;
&lt;p&gt;
Following the tradition of giving XML languages names that are barely-logical acronyms beginning with &lt;q&gt;X&lt;/q&gt;, I call the language &lt;abbr title=&quot;XML... Twaddle... something&quot;&gt;XTw&lt;/abbr&gt;, which stands for &lt;q&gt;XML... Twaddle... something&lt;/q&gt;.
&lt;/p&gt;
&lt;p&gt;
Here&#x27;s how I worked the magic (borrowing liberally from a newsgroup posting I made on the subject):
&lt;/p&gt;
&lt;p&gt;
This assumes: no programming experience, but enough computer savvy to create XML and XSL files to need transforming in the first place; and a Windows (XP) machine)
&lt;/p&gt;
&lt;p&gt;
First off, you&#x27;ll need Xalan, available from http://xml.apache.org/xalan-j/ (and the requisite Java runtime, which you probably already have)
&lt;/p&gt;
&lt;p&gt;
The actual file I downloaded was http://apache.rmplc.co.uk/dist/xml/xalan-j/xalan-j-current-bin.tar.gz
&lt;/p&gt;
&lt;p&gt;
There&#x27;s also http://apache.rmplc.co.uk/dist/xml/xalan-j/xalan-j-current-bin.zip if you prefer a zip.
&lt;/p&gt;
&lt;p&gt;
The version I got was 2.6.0 (the Java version).
&lt;/p&gt;
&lt;p&gt;
Unzip Xalan into a folder. I used C:\Program Files\xalan-j_2_6_0
&lt;/p&gt;
&lt;p&gt;
Now the code from http://evc-cit.info/cit041x/batchfiles.html#transform:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;echo off
&lt;br/&gt;java -cp h:\java\xmljar\xalan-j_2_5_1\bin\xml-apis.jar;h:\java\xmljar\xalan-j_2_5_1\bin\xercesImpl.jar;h:\java\xmljar\xalan-j_2_5_1\bin\xalan.jar;. org.apache.xalan.xslt.Process -IN %1 -XSL %2 -OUT %3 %4 %5 %6 %7 %8 %9&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The only line break should be after &lt;q&gt;echo off&lt;/q&gt;.
&lt;/p&gt;
&lt;p&gt;
Copy this into a plain text editor (e.g. Notepad), and save it as filename.bat (I used ANSI encoding, if it matters)
&lt;/p&gt;
&lt;p&gt;
You should now have an MS-DOS Batch File.
&lt;/p&gt;
&lt;p&gt;
(Apparently some versions of Notepad append &lt;q&gt;.txt&lt;/q&gt; to filenames, even if they contain a file &lt;q&gt;extension&lt;/q&gt;. In these cases, quoting the filename - e.g. “filename.bat” - allegedly solves the problem)
&lt;/p&gt;
&lt;p&gt;
You&#x27;ll most likely have to modify the code to point to the actual locations of your Xalan installation and files.
&lt;/p&gt;
&lt;p&gt;
I only plan on using one XSL stylesheet with multiple files; the input files will be filename.xml. The output files will be filename.htm and will be kept in the folder above the one where the input and XSL files are kept. So, I modified the code a little:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;java -cp &quot;c:\program files\xalan-j_2_6_0\bin\xml-apis.jar&quot;;&quot;c:\program files\xalan-j_2_6_0\bin\xercesImpl.jar&quot;;&quot;c:\program files\xalan-j_2_6_0\bin\xalan.jar&quot;;. org.apache.xalan.xslt.Process -IN %1.xml -XSL &quot;c:\path\to\an\xsl\file\xsl.xml&quot; -OUT ..\%1.htm&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
This should all be on one line. &lt;q&gt;%1&lt;/q&gt; in the code will be replaced by the first argument passed to the batch file, &lt;q&gt;%2&lt;/q&gt; by the second argument, etc. &lt;q&gt;..\&lt;/q&gt; means &lt;q&gt;up one folder&lt;/q&gt;. The quotation marks around the filenames cause them to be treated as one item, despite their containing spaces.
&lt;/p&gt;
&lt;p&gt;
You can add &lt;q&gt;@echo off&lt;/q&gt; (without quotes) in an empty line above, if you prefer not to have masses of textual output in the command console. e.g.:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;@echo off
&lt;br/&gt;java -cp &quot;c:\...&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;q&gt;echo off&lt;/q&gt; turns off the display of subsequent commands; &lt;q&gt;@&lt;/q&gt; hides the echo off command.
&lt;/p&gt;
&lt;p&gt;
To perform the transformation, open a command console (Start &amp;gt; Run &amp;gt; &lt;code&gt;&quot;cmd&quot;&lt;/code&gt;) and navigate to the location of your XML, XSL and batch files, by typing
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;cd &quot;c:\path\to\files&quot;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
(including the quotes)
&lt;/p&gt;
&lt;p&gt;
For simplicity&#x27;s sake, I&#x27;ve shoved everything in the same folder, and used absolute paths for the programs. You could probably also mess around with relative paths or the path environment variable, but I can&#x27;t be bothered.
&lt;/p&gt;
&lt;p&gt;
I ended up having to use &lt;a href=&quot;http://tidy.sourceforge.net/&quot;&gt;HTML Tidy&lt;/a&gt; to contort the output into valid XHTML. My final batch file reads:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;java -cp &quot;c:\program files\xalan-j_2_6_0\bin\xml-apis.jar&quot;;&quot;c:\program files\xalan-j_2_6_0\bin\xercesImpl.jar&quot;;&quot;c:\program files\xalan-j_2_6_0\bin\xalan.jar&quot;;. org.apache.xalan.xslt.Process -IN %1.xtw -XSL &quot;XTw2XHTML.xsl&quot; -OUT ..\thetwaddle\%1.htm
&lt;br/&gt;
&lt;br/&gt;&quot;C:\Program Files\HTMLTidy\tidy.exe&quot; -q -m -c --show-warnings no --output-xml yes --output-xhtml yes -latin1 --doctype strict --tidy-mark no --wrap 0 --ascii-chars no --drop-proprietary-attributes yes --fix-bad-comments no ..\thetwaddle\%1.htm
&lt;br/&gt;
&lt;br/&gt;echo Done %1.&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
(Line breaks have been doubled for clarity.)
&lt;/p&gt;
&lt;p&gt;
The input XML files are all labelled &lt;q&gt;filename.xtw&lt;/q&gt;; the XSL stylesheet is &lt;q&gt;XTw2XHTML.xsl&lt;/q&gt;, and the output files are cacked into the folder &lt;q&gt;thetwaddle&lt;/q&gt;, a sibling of the folder where the batch file lives, and assigned a suffix of &lt;q&gt;.htm&lt;/q&gt;.
&lt;/p&gt;
&lt;p&gt;
Those options shown for Tidy are the result of trial and error, or rather, trial and testing and reading Tidy&#x27;s &lt;a href=&quot;http://tidy.sourceforge.net/docs/quickref.html&quot;&gt;Quick Reference&lt;/a&gt; - no warranty implied. The &lt;q&gt;echo&lt;/q&gt; command prints out a message for each finished file.
&lt;/p&gt;
&lt;p&gt;
This batch file is wrapped up in another one, which repeatedly calls the first, thus:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;@echo off
&lt;br/&gt;echo Transforming XTw into XHTML...
&lt;br/&gt;call xtw2xhtml afile
&lt;br/&gt;call xtw2xhtml otherfiles
&lt;br/&gt;echo Done.&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
The text output is just to make the command console more interesting while the batch program is running. It also helps pinpoint any errors, such as typos, which show up as blobs of text in the command console.
&lt;/p&gt;
&lt;p&gt;
The result of all this fiddling is that I can change pages&#x27; contents more easily; I&#x27;ve been able to, fairly easily, implement a few minor changes that would have taken effort before. The final product lives &lt;a href=&quot;/thetwaddle&quot;&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
In semi-related news, it turns out that PURLs such as &lt;a href=&quot;http://purl.org/mooquackwooftweetmeow&quot;&gt;purl.org/mooquackwooftweetmeow&lt;/a&gt;, without the trailing slash, are possible - it&#x27;s just partial redirects that have to end with slashes. The Twaddle&#x27;s now on PURLs, too - &lt;a href=&quot;http://purl.org/thetwaddle/&quot;&gt;purl.org/thetwaddle&lt;/a&gt; - with or without the slash.
&lt;/p&gt;
&lt;p&gt;
While uploading “Unleash The Twaddlebot!” (The Twaddle v1.0), I was reminded that we&#x27;re approaching the 50-file limit; that&#x27;s not including styles, which are kept in a separate account. This means we&#x27;ll probably have to change hosts.
&lt;/p&gt;
&lt;p&gt;
Fortunately, ntl provide 55 megabytes of space, so I&#x27;m planning to shift everything there. This shouldn&#x27;t be too troublesome now that everything&#x27;s on PURLs.
&lt;/p&gt;</content></entry>
<entry><title>Adventures in XML</title><id>https://gkn.me.uk/weblog028</id><link href="https://gkn.me.uk/weblog028" rel="alternate" type="text/html"/><published>2004-04-27T17:40:00+00:00</published><updated>2004-06-07T18:40:00+00:00</updated><content type="html">
&lt;p&gt;
I did manage to get the XML+XSL-based jiggery-pokery for The Twaddle working - quite nicely, actually. Getting the entire contents of the content field onto the page took a little bit of effort, as described &lt;a href=&quot;http://forums.mozillazine.org/viewtopic.php?t=71322&amp;amp;sid=7848e3b9bfb83d57adacdde5f19433e9&quot;&gt;on the mozillaZine forums&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I won&#x27;t be implementing this on The Twaddle, though - for a start, Opera and KHTML don&#x27;t like XSLT. And it&#x27;s not half as accessible for non-standard browsers (relics, mobile devices, text browsers...) as plain, extraneous-menu-items-and-such-written-into-the-article XHTML is. Nonetheless, a working example is online for the time being.
&lt;/p&gt;
&lt;p&gt;&lt;ins&gt;
Update: the real thing&#x27;s gone live... sort of... so the prototype has been removed. Additional related blurb is contained in &lt;a href=&quot;/weblog035&quot;&gt;a later entry in this weblog&lt;/a&gt;.
&lt;/ins&gt;&lt;/p&gt;
&lt;p&gt;
There&#x27;s a slight chance that I might implement an XML-driven article system on Mooquackwooftweetmeow, where I&#x27;m not too fussed about &lt;a href=&quot;http://microsoft.com/ie&quot;&gt;old and/or buggy browsers&lt;/a&gt;. The fact that mobile devices won&#x27;t render the page is more of a concern.
&lt;/p&gt;
&lt;p&gt;
Perhaps some way of pulling in external XHTML fragments could be handled in CSS3? Then again, why duplicate XSL functionality in CSS - small devices&#x27; browsers could just be taught to handle XSL.
&lt;/p&gt;
&lt;p&gt;
One more Twaddle-related thing: thanks to &lt;a href=&quot;http://www.quirksmode.org/css/condcom.html&quot;&gt;Internet Explorer conditional comments&lt;/a&gt; (on which MSDN has &lt;a href=&quot;http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp#Conditional_Comments_Terminology&quot;&gt;an hilarious article&lt;/a&gt;), I&#x27;m now feeding IE users &lt;a href=&quot;http://purl.org/thetwaddle/home/index.html#spur&quot;&gt;some nice propaganda in the foot of the front page&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;
&lt;q&gt;You&#x27;re using Internet Explorer?! You do realise that it&#x27;s years out-of-date, and screws up most modern web pages, don&#x27;t you? In fact it&#x27;s screwing this one up right now and you don&#x27;t even know it. Try &lt;a href=&quot;http://www.mozilla.org/products/firefox/&quot;&gt;a proper web browser&lt;/a&gt; instead.&lt;/q&gt;
&lt;/p&gt;
&lt;p&gt;
Oh, and another tiny little piece of The Twaddle-related trivia: the version number on the front page is now in the title text of the &lt;a href=&quot;http://purl.org/thetwaddle/home/index.html#copyright&quot;&gt;copyright notice&lt;/a&gt; - it&#x27;s tidier and it leaves room for a pointless codename.
&lt;/p&gt;
&lt;p&gt;
Over to the Mooquackwooftweetmeow Weblog now, where, thanks to our old friend XML namespaces, and our newer friend &lt;a href=&quot;http://forums.mozillazine.org/viewtopic.php?t=71322&amp;amp;sid=7848e3b9bfb83d57adacdde5f19433e9&quot;&gt;the XSL &lt;code&gt;copy-of&lt;/code&gt; element&lt;/a&gt;, proper links are now in use. I&#x27;ve gone back through the weblog and updated plain text URLs to be links. The more observant of you will have noticed that there have been a smattering of links throughout this post - that&#x27;ll be the norm from now on.
&lt;/p&gt;
&lt;p&gt;
The even more observant of you will have noticed line breaks as well. I&#x27;d use paragraphs but the XSL stylesheet inserts the content into a paragraph - I don&#x27;t think the &lt;a href=&quot;http://validator.w3.org&quot;&gt;XHTML validator&lt;/a&gt; would like paragraphs within paragraphs (not that it&#x27;d like this Atom file at all...). And I don&#x27;t think the site&#x27;s CSS would like &lt;code&gt;div&lt;/code&gt;s to hold the text, in place of paragraphs; it might - I just haven&#x27;t looked at mqwtm&#x27;s CSS in ages so I can&#x27;t remember. Besides, line breaks are lighter on the markup than open-and-close &lt;code&gt;&amp;lt;xhtml:p&amp;gt;&lt;/code&gt; tags.
&lt;/p&gt;
&lt;p&gt;
And in a final twist of XMLish loveliness, I&#x27;ve chucked a few XHTML &lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt; tags in as well.
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;&amp;lt;/epic&amp;gt;&lt;/code&gt;
&lt;/p&gt;</content></entry>
<entry><title>Opera + XSL = Eugh</title><id>https://gkn.me.uk/weblog027</id><link href="https://gkn.me.uk/weblog027" rel="alternate" type="text/html"/><published>2004-04-23T14:16:00+00:00</published><updated>2004-04-23T14:16:00+00:00</updated><content type="html">
&lt;p&gt;
Evidently Opera doesn&#x27;t like XSL - this weblog shows up as a lot of plain text with the odd URL chucked in. The question is whether I care.
&lt;/p&gt;
&lt;p&gt;
The Twaddle is more of a public offering than this weblog, so it matters a little more if it&#x27;s inaccessible using Opera... but then how many readers of The Twaddle use Opera? I&#x27;d say few to none. (Checking the site stats for The Twaddle will probably show a few Opera hits - most of which are me).
&lt;/p&gt;</content></entry>
<entry><title>IE + XML + XSL + XHTML + W3C = Get In!</title><id>https://gkn.me.uk/weblog026</id><link href="https://gkn.me.uk/weblog026" rel="alternate" type="text/html"/><published>2004-04-23T14:07:00+00:00</published><updated>2004-04-23T14:07:00+00:00</updated><content type="html">
&lt;p&gt;
As a prelude to some major back-end renovation I&#x27;m planning for The Twaddle, I decided to see if I could get Internet Explorer 6 to display this XSL-ified weblog nicely, not accounting for IE-unsupported CSS (which is already taken care of at The Twaddle). Previously, IE displayed the DOCTYPE declaration as plain text at the top of the page; using strategic HTML commenting, I&#x27;ve managed to prevent it from doing so.
&lt;/p&gt;
&lt;p&gt;
Actually, I bet simply removing the DOCTYPE declaration wouldn&#x27;t affect either Gecko or IE&#x27;s rendering of the page, as I think XML kicks both of them into standards mode anyway.
&lt;/p&gt;
&lt;p&gt;
The next step is to try this with some of The Twaddle. And I&#x27;d probably best check Opera&#x27;s effort, too.
&lt;/p&gt;</content></entry>
<entry><title>Hurrah once more!</title><id>https://gkn.me.uk/weblog001</id><link href="https://gkn.me.uk/weblog001" rel="alternate" type="text/html"/><published>2004-02-19T14:20:00+00:00</published><updated>2004-02-19T14:20:00+00:00</updated><content type="html">
&lt;p&gt;
That w3schools (&lt;a href=&quot;http://www.w3schools.com/&quot;&gt;http://www.w3schools.com/&lt;/a&gt;) is pretty decent. I&#x27;ve now concocted an XSL stylesheet for this feed, so visiting its URL in a (good) web browser should display it as a nice page.
&lt;/p&gt;
&lt;p&gt;
I managed to cajole XML namespaces into doing what I want with a little help from a random blog entry (&lt;a href=&quot;http://today.icantfocus.com/blog/archives/entries/000430/&quot;&gt;http://today.icantfocus.com/blog/archives/entries/000430/&lt;/a&gt;) by Christopher H. Laco, and his one-size-fits-all feed stylesheet. Those who are interested can have a gander at my resulting stylesheet (&lt;a href=&quot;http://purl.org/mooquackwooftweetmeow/weblog.xsl.xml&quot;&gt;http://purl.org/mooquackwooftweetmeow/weblog.xsl.xml&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
Next job: rig up a klip.
&lt;/p&gt;</content></entry>
<entry><title>Hurrah!</title><id>https://gkn.me.uk/weblog000</id><link href="https://gkn.me.uk/weblog000" rel="alternate" type="text/html"/><published>2004-02-19T13:00:00+00:00</published><updated>2004-02-19T13:00:00+00:00</updated><content type="html">
&lt;p&gt;
Well, then... this is an atom weblog. Why&#x27;s it only in atom format? Everything on Mooquackwooftweetmeow is done the old-fashioned way - using the human brain, a plain-text editor, and no PHP, ASP, SQL or any other fanciness. And I don&#x27;t want to have to copy every entry out into an XHTML page. I&#x27;m thinking of having a bash at some XSLT, to automatically generate a fancy front for the weblog; I tried it with the RSS feed, but didn&#x27;t quite manage it satisfactorily; perhaps my standards are just too high (after all, I am using a free web host).
&lt;/p&gt;</content></entry>
</feed>