To add onto bobince's answer... If whatever tool/library you using uses Xpath 2.0, you can also do this:
//*[count(index-of(tokenize(@class, '\s+' ), $classname)) = 1]
count() is apparently needed because index-of() returns a sequence of each index it has a match at in the string.