Move self-closing tags logic back to compiler so it works with xml

[closes #1448][closes #1464]

Also makes invalid filter-name errors get reported with the correct line
numbers and correctly reports errors when we have no idea what line/file
the error is in.