Building a CMS using XML, XSLT, Ant and ImageMagick

January 3rd, 2010

Not so long ago a freelance client approached me with some updates for their website. The site has been growing organically since 2000 and therefore was a big mess. Several attempts to port the site to a CMS driven system failed largely because those CMS systems are usually to complex for our needs (Typo3) or not flexible enough (Joomla, Wordpress). So as I was faced with updates to all the updates including image updates which in turn needed thumbnails to be generated. The same day I stumbled randomly over the xsl:result-document function in XSLT 2.0 which allows you to transform a single XML file into several output files. That sparked an idea with me: why not use that to build a CMS system using XML technologies? I’ve toyed around with Cocoon a couple of years ago but that was not what I was looking for. So I looked for other technologies…

This post is a write-down of my experiences building a XML/XSLT driven simple CMS system. In it I will show you the required technologies, my approaches and my solutions to problems I’ve encountered. You’ll need a solid understanding of XML at least, understanding of Ant and XSLT helps a lot, too.

This post contains tons of XML and I tried my best to format it in a readable way — in fact I’ve spent hours to get everything nicely on the screen.
Read the rest of this entry »

Liquibase Incremental DB Diff

December 12th, 2009

After discussing this on the Groovy and Grails Exchange, I finally put together a new version of the db diff script that I’ve mentioned in an earlier post. I couldn’t find the original version that I’ve written a couple of months ago, so I hacked together a new one. It’s far from perfect, efficient or beautiful, but it does what it is supposed to.

So, what’s the idea behind this script? Everybody that uses Liquibase (if you are not, check out my blog post about what Liquibase is and how to use it) knows how painful it is to update your changelog.xml. Liquibase already gives you a great tool to start with, the db-diff command. However, it is hardcoded to diff the current environment’s database against the test database. This is annoying as you’ll have to modify your datasources and keep the database schema updated manually. But fear not, here is my (surprisingly) easy solution.

I’ve created a simple script (or rather, I took the db-diff script and hacked it), which I’ve called incremental DB diff (all the other cool names are already taken…) and what it does is the following:

  1. update the schema in the db-diff (or whatever you call it) database using the changelog.xml
  2. diff the database of the current environment against this database and output the diff as Liquibase XML

So, how is this a good thing? Easy: this little script will automatically create a target database to diff against using the changelog.xml which is good, as the changelog.xml represents your last migration status. And as it uses a separate database it doesn’t influence the test database.

After running the script just put the output in the changelog.xml and you’re done.

All you have to do to use this is to drop the file into your /scripts/ directory, create a new database and an according datasource entry for the environment “dbdiff” like this:

	dbdiff {
		dataSource {
			driverClassName = "com.mysql.jdbc.Driver"
			dbCreate = "create-drop"
			url = "jdbc:mysql://localhost/foo_dbdiff"
			username = "foo"
			password = "bar"
		}
	}

Download DbDiffIncremental.groovy. Drop me a mail or a comment if you have questions.

Grails GraniteDS Plugin and Flex Modules – Could not resolve ? to a component implementation

October 2nd, 2009

I’m currently working a lot with the Grails GraniteDS plugin. Just recently I’ve started to separate my application into modules and ran into a really nasty error.

It took me some time to figure it out, hopefully I can save you from going through all this.

The Flex web tier compiler usually gives me this error:

Error: Could not resolve <namespace:Component> to a component implementation.

 <namespace:Component/>

error during compilation Could not resolve <namespace:Component> to a component implementation.

Initial research confirmed what I thought, this error is caused by a mismatch between a XML namespace declaration and the actual location of a component. However the location and the namespace declaration looked right and the issue occurred only after I had moved the questionable component into a separate module.

After two painful hours I realized that the Flex webtier compiler, as configured with GraniteDS, resolves namespaces relative to modules, not relative to the source folder. D’oh!

The solution I came up with was simple, might be naïve though. I figured that if resolution is relative to the Module and not to the source folder, there might be no such source folder as I would expect it. A quick look into the flex-config.xml found in <GRAILS_PROJ>/web-app/WEB-INF/flex/flex-config.xml confirmed this:

<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
 <!-- not set -->
 <!--
 <source-path>
 <path-element>string</path-element>
 </source-path>
 -->

So there is no explicit source path set. So I changed it so it would point to <GRAILS_PROJ>/grails-app/views/flex:

<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
 <!-- not set -->
 <source-path>
 <path-element>../../../grails-app/views/flex</path-element>
 </source-path>

Voilá – it works. However, as mentioned earlier, this might be a very limited solution, but for now it works.

Panorama – Château Villandry II

September 26th, 2009

And here is my second panorama from Château de Villandry. This particular one has been made from the stairs leading to the vegetable gardens.

Vegetable Gardens at Château de Villandry

Vegetable Gardens at Château de Villandry

Panorama – Château Villandry

September 22nd, 2009

I finally managed to create my panorama from Château Villandry in France. I missed one image so there’s an ugly gray border on the bottom left. Other than that it’s a really beautiful panorama, you can see almost all the gardens. Enjoy. (Click for high-res version!)

Panorama of Château Villandry and its Gardens

Panorama of Château Villandry and its Gardens

Zurück nach Deutschland

September 20th, 2009

Die letzten Wochen waren unheimlich ereignisreich. Meine Zeit bei Mindblossom ist vorüber aber die letzten 2 Wochen dort war ich nicht untätig. Ein letztes Projekt mit unheimlich enger Deadline musste (und wurde) gestemmt: Rona 70th Anniversary. Danach ging es mit viel Freelance Arbeit weiter. Heute habe ich endlich ein wenig Luft und ich plane meine Rückkehr nach Deutschland. Der Flug ist gebucht und ich werde am kommenden Donnerstag um 16:50 in München aufschlagen.

Heute habe ich auch endlich mal die Bilder von meinem Handy heruntergeladen und da ein paar schöne Schmankerl aus den letzten Monaten dabei sind, habe ich sie hier hochgeladen. Enjoy.

Paris, Tag 2

June 29th, 2009

Tag zwei in Paris. Nachdem wir den halben Tag wegen meines Jetlags verpasst haben, sind wir erstmal zum Essen raus. Danach ging es zu weiteren Sehenswürdigkeiten und einer Bootstour. Brüllend heiß und Paris ist ziemlich… nun ja, es riecht überall. ;) Bin wohl von der guten Luft in Toronto verwöhnt. Morgen fahren wir nach Versailles. Juhuu.

Geburtstag und Erster Tag in Paris

June 28th, 2009

So, sicher in Paris gelandet nach einem mehr oder minder ereignisfreien Flug, mal abgesehen davon das mein Sitznachbar wohl Blähungen hatte. Vom Flughafen ging es direkt nach Paris wo ich Manne und Lily getroffen habe. Danach ging es direkt nach Paris, ein paar Sehenswürdigkeiten ansehen und in einem idyllischen Straßencafé Geschichten austauschen und auf den Neusten Stand bringen.

Meine Mailbox, Facebook und Lokalisten quillt über vor lieben Geburtstagsgrüßen. Vielen vielen lieben Dank an alle! :)

Ninja Coding Monkey goes France. And Germany.

June 26th, 2009

So Freunde, es ist soweit. Heute geht es zurück nach Europa. Nur für eineinhalb Wochen, aber immerhin. Heute Abend geht es mit dem Flieger nach Paris, wo ich erstmal bei meinem alten Mitbewohner Manne unterkommen werde. Von dort aus geht es weiter nach Versailles und in das Loires Tal. Bin schon ziemlich aufgeregt.

Nächste Woche Freitag geht es weiter zurück nach München. Das Programm ist voll. Ich will Lily München und ein paar Sehenswürdigkeiten in Bayern zeigen, Freunde besuchen und natürlich ein wenig Zeit mit meiner Familie verbringen.

Bis denn.

Toronto Island, 1000 Tastes of Toronto und ein Abstecher nach Deutschland

June 14th, 2009

Nach langer Pause endlich wieder eine Post. Die letzten Wochen waren ereignisreich.

Am Freitag vor zwei Wochen ist Lily’s Hund Tiger nach einem Unfall von uns gegangen. RIP Tiger. :’(

Nun aber zu besseren Nachrichten. Den heutigen Samstag haben Lily und ich auf Toronto Island verbracht. Habt ihr euch gefragt woher diese atemberaubenden Bilder von der Toronto Skyline kommen? Ja genau, von Toronto Island. Man hat die gesamte Skyline im Blick. Aber seht selbst…

Auf Toronto Island haben wir ein einem Volleyballturnier zu wohltätige Zwecken teilgenommen. An dieser Stelle sollte ich wohl anmerken das ich seit 2003 nicht mehr Volleyball gespielt habe. Aber das war ok nachdem wir in der Anfängerliga waren. Und keines der Teams war wirklich besser als wir. Oder eigentlich doch, denn irgendwie haben wir jedes Spiel bis auf zwei – einmal weil die andere Mannschaft nicht da war und einmal war ein unentschieden – verloren haben. Macht nix, hat Spaß gemacht. Außerdem haben wir so viele Hunde gesehen. Von Huskeys so groß wie ein Kalb bis zu Golden Retrievern und Black Labs so ziemlich alles.

Später gings dann zum 1000 Tastes of Toronto Festival am Queens Quay, so eine Art kulinarischer Jahrmarkt. So ziemlich jedes bessere Restaurant in Toronto war mit einem Stand vertreten. Die Bilder sprechen für sich…

Und zu allerletzt: Ich komme im Juli über das Wochenende 4. und 5. nach Deutschland. :) Ich bin nur ein paar Tage da aber ich hoffe es ist genug Zeit euch alle wiederzusehen.