2009-11-06T20:34:20+01:00

7. XSLT hammer

There are couple of transformations done using XSLT for ba.pm.org page. Using XSLT from one XML file the RSS feed (.rdf) and events page (.tt2) is generated. From another XML file the who is who page and JavaScript for Google maps is generated. Thanks goes to potyl for having patience and time doing these!

From Makefile:

html/en/news.rdf: etc/events.xml tt/dtd/events-1.0.dtd xslt/events-to-rdf.xslt
	xmllint --valid --noout $<
	xsltproc --stringparam lang en --nodtdattr xslt/events-to-rdf.xslt $< > $@

tt/events.tt2-en: etc/events.xml xslt/events-to-html.xslt tt/dtd/events-1.0.dtd
	xmllint --valid --noout $<
	xsltproc --stringparam lang en --nodtdattr xslt/events-to-html.xslt $< > $@

tt/who.tt2: etc/who.xml xslt/who-to-html.xslt
	xmllint --valid --noout $<
	xsltproc --nodtdattr xslt/who-to-html.xslt $< > $@

src/js/06_mongers.js: etc/who.xml xslt/who-to-js.xslt
	xmllint --valid --noout $<
	xsltproc --nodtdattr xslt/who-to-js.xslt $< > $@

So what so good about XSLT? It is made to do XML transformations. From XML to anything as you've seen in the above examples. Here is a collection of links pointing to XSLT related pages:

XSLT stylesheet can include other stylesheets with matchers, can override the ones defined earlier and it can do some other nasty hacks. You can do pretty much anything, although it may not be the best idea. Like in Perl...

comments powered by Disqus