Changeset 2098


Ignore:
Timestamp:
08/15/12 13:39:03 (12 years ago)
Author:
oschonef
Message:
  • fix invalid XML response if scan operation yielded no results
File:
1 edited

Legend:

Unmodified
Added
Removed
  • SRUServer/trunk/src/main/java/eu/clarin/sru/server/SRUServer.java

    r1990 r2098  
    243243
    244244            try {
    245                 out.writeStartElement(SRU_NS, "terms");
     245                boolean wroteTerms = false;
     246                /*
     247                 * a scan result without a list of terms is a valid response;
     248                 * make sure, to produce the correct output and omit in that case
     249                 * the <terms> ...
     250                 */
    246251                while (result.nextTerm()) {
     252                    if (!wroteTerms) {
     253                        out.writeStartElement(SRU_NS, "terms");
     254                    }
    247255                    out.writeStartElement(SRU_NS, "term");
    248256
     
    291299                    out.writeEndElement(); // "term" element
    292300                } // while
    293                 out.writeEndElement(); // "terms" element
     301                if (wroteTerms) {
     302                    out.writeEndElement(); // "terms" element
     303                }
    294304            } catch (NoSuchElementException e) {
    295305                throw new SRUException(SRUConstants.SRU_GENERAL_SYSTEM_ERROR,
Note: See TracChangeset for help on using the changeset viewer.