Trim phrases of arbitrary length to a maximum length, without cutting off words or ending on unwanted words, with XQuery