Add some validation to elements before attempting to process them, in order to avoid falling prey to upstream compilation problems causing thrown exceptions rather than reported errors.