refine if/else branching in formatAttributeValue()