Computer Programming

Computer related pages.
Scala's XPath-like XML queries
Scala's XPath-like xml query functions combine nicely with for-comprehension syntax to support query functionality that is almost as powerful as XPath (without the parent and sibling axes, of course, which are not available in scala's purely functional xml implentation, and limited namespace support).
Parsing HTML as if it were XML in scala
Sometimes you want to process real world HTML as if it were XML in scala. This is in fact quite easy, since you can use any library that can generate SAX events to construct an XML data structure in scala and there are some packages that can generate SAX events from more or less broken HTML input.
Variance with Horses and People
Recently, some people on one of the scala mailing lists got into the usual discussion on covariance and contravariance, when somebody correctly remarked that the best illustration variance is the trait Function1[-A,+B], which shows both types of variance in a single, simple package. Here are the pictures requested in that thread.
Using JPA with Scala
With JPA, you should be able to add a few standardized annotations to classes that represent the entities of your application and get an easy to use, vendor neutral persistence layer that you can use with different persistence providers without changing your code. I perfomed some test how far you can get with different engines if you write your code in scala. As it turns out, your scala JPA entities are vendor neutral if and only if your vendor is eclipselink.
How (not) to build buildr on Ubuntu Intrepid
Buildr claims to be a build tool for java applications, but it barely builds at all and works only if you don't use a current version of java. But if you really need it, you can compile it on Ubuntu if you ignore the official how-to.
Real world HTML in Scala
Sometimes you want to process real world HTML as if it were XML in scala. This is in fact quite easy, since you can use any library that can generate SAX events to construct an XML data structure in scala and there are some packages that can generate SAX events from more or less broken HTML input. Using DOM2SAX from Xalan, you can also use HTML sanitizers that build a DOM.
VCS Cheats Sheets
It looks like there will be no clear winner in the »we need something better than CVS« race, and we will probably all be forced to deal with more than one VCS if we want to follow several projects.
Florian Hars <florian@hars.de>, 2014-02-26 (orig: 2008-04-25)