for //text() { if xsh:match(., '^\s+$') set . '' } #### for //text() { if ((following-sibling::* or preceding-sibling::*) and xsh:match(., '^\s+$')) set . '' }