Currently, cursor_to_xml returns an empty string when the end of the
cursor is reached (meaning the fetch returned zero rows). As discussed
on -general, that's kind of weird, because you'd have to do something
like
IF val::text = ''
to test for the end, since there is no = operator for xml, and also
because '' isn't a valid XML value at all.
What would be a good way to address this? Return null perhaps?