More Coverity fixes

Lot of xslt fixes. There are a couple of issues that i don't know how to sort out, please take a look at CID 1125159 and 1125161.