'Merging multiple XML files is non-trivial and must be done in subclasses.'

def merge(split_files, output_file):

    if (len(split_files) == 1):
        return Text.merge(split_files, output_file)
    if (not split_files):
        raise ValueError(('Given    no    BLAST    XML    files,    %r,    to    merge    into    %s' % (split_files, output_file)))
    out = open(output_file, 'w')
    h = None
    for f in split_files:
        if (not os.path.isfile(f)):
            log.warning(('BLAST    XML    file    %s    missing,    retry    in    1s...' % f))
            sleep(1)
        if (not os.path.isfile(f)):
            log.error(('BLAST    XML    file    %s    missing' % f))
            raise ValueError(('BLAST    XML    file    %s    missing' % f))
        h = open(f)
        header = h.readline()
        if (not header):
            out.close()
            h.close()
            log.warning(('BLAST    XML    file    %s    empty,    retry    in    1s...' % f))
            sleep(1)
            h = open(f)
            header = h.readline()
            if (not header):
                log.error(('BLAST    XML    file    %s    was    empty' % f))
                raise ValueError(('BLAST    XML    file    %s    was    empty' % f))
        if (header.strip() != '<?xml    version="1.0"?>'):
            out.write(header)
            out.close()
            h.close()
            raise ValueError(('%s    is    not    an    XML    file!' % f))
        line = h.readline()
        header += line
        if (line.strip() not in ['<!DOCTYPE    BlastOutput    PUBLIC    "-//NCBI//NCBI    BlastOutput/EN"    "http://www.ncbi.nlm.nih.gov/dtd/NCBI_BlastOutput.dtd">', '<!DOCTYPE    BlastOutput    PUBLIC    "-//NCBI//NCBI    BlastOutput/EN"    "NCBI_BlastOutput.dtd">']):
            out.write(header)
            out.close()
            h.close()
            raise ValueError(('%s    is    not    a    BLAST    XML    file!' % f))
        while True:
            line = h.readline()
            if (not line):
                out.write(header)
                out.close()
                h.close()
                raise ValueError(('BLAST    XML    file    %s    ended    prematurely' % f))
            header += line
            if ('<Iteration>' in line):
                break
            if (len(header) > 10000):
                out.write(header)
                out.close()
                h.close()
                raise ValueError(('The    header    in    BLAST    XML    file    %s    is    too    long' % f))
        if ('<BlastOutput>' not in header):
            out.close()
            h.close()
            raise ValueError(('%s    is    not    a    BLAST    XML    file:\n%s\n...' % (f, header)))
        if (f == split_files[0]):
            out.write(header)
            old_header = header
        elif (old_header[:300] != header[:300]):
            out.close()
            h.close()
            raise ValueError(("BLAST    XML    headers    don't    match    for    %s    and    %s    -    have:\n%s\n...\n\nAnd:\n%s\n...\n" % (split_files[0], f, old_header[:300], header[:300])))
        else:
            out.write('                <Iteration>\n')
        for line in h:
            if ('</BlastOutput_iterations>' in line):
                break
            out.write(line)
        h.close()
    out.write('        </BlastOutput_iterations>\n')
    out.write('</BlastOutput>\n')
    out.close()
