added an sprintf %s to convert $role to string
the result of XPath query is not a string but an object