def _combine_with_space(prev_text, next_text, add_space_if_needed):
    """Logic to determine where to add spaces to XML. Generally this is just
    as matter of checking for space characters, but there are some
    outliers"""
    prev_text, next_text = prev_text or '', next_text or ''
    prev_char, next_char = prev_text[-1:], next_text[:1]
    needs_space = (not prev_char.isspace() and not next_char.isspace() and
        next_char and prev_char not in u'([/<—-' and next_char not in
        u').;,]>/—-')
    if add_space_if_needed and needs_space:
        return prev_text + ' ' + next_text
    else:
        return prev_text + next_text
