I realize that I have been waaay to little geeky in my recent posts, so here is some real geeky XSLT tips:
XSLT 2.0/XQuery 1.0 has support for regular expressions which can be useful if you are processing an XML file with elements with different alphabets and you only want to display the elements in one of the alphabets. Russian and a few other languages for example uses the Cyrillic alphabet wich is defined in the unicode range from 0x0400 to 0x052F. The following snippet does the trick:
We speak russian!
Bi-lingual XSLT transformation
You can easily do bi-lingual XSLT transformations. If you want to display values in different language dependening on some external parameter, I have found the following to do the job:
translation.xml looks like this:
cheers Cheers! Skål! Proost!
With XSLT 2.0 you can use an extra attribute «order-by» in your for-each to specify what element to sort by (with an optional + or – in front to indicate ascending or descending sorting). If you’re using XSLT 1.0 however, you have to do it slightly different. The following snippet will print out the name of the latest hired employee in every departement (sorted by the date hired):