Match elements by case-insensitive type/role attributes

Closes #573