parse errors in xsl files should be logged, cleanup code as well

some previous commit had dropped logging xsl parse errors to log file, so
make sure that applies. shuffled code around to make it cleaner and drop
redundant code, this has no functional change.