Better XdmNode to InputSource conversion

The proposed change serializes the XdmNode to a temporary ByteArray instead of a String. It's more efficient and prevents some OutOfMemoryErrors.