rem: debug.print("cqExport: preserving selected database " + oldDatabase); 
context: function cqExport(theForm) {    // export store the buffer state into the value of form element g_cq_uri    // if the g_cq_uri does not exist, we must create it in one XQuery,    // then populate it in another    // the simplest way is to create temporary form elements, and submit them    // TODO export non-default options (rows, cols, etc), export them    var theUri = trim(document.getElementById(g_cq_uri).value);    if (! theUri) {      return null;    }    var theQuery =        'xdmp:document-insert("' + theUri + '",'        + '<' + g_cq_buffers_area_id + ' id="' + g_cq_buffers_area_id + '">';    // save buffers    // childNodes.length will return some non-buffer elements, too!    var buf = null;    // parent of all the textareas    var theParent = document.getElementById(g_cq_buffers_area_id);    for (var i = 0; i < theParent.childNodes.length; i++) {        buf = getBuffer(i);        if (buf != null) {            theQuery += '<' + g_cq_buffer_basename + '>'                // TODO xml-escape, instead?                + encodeURIComponent(getBuffer(i).value)                + '</' + g_cq_buffer_basename + '>'                + "\n";        }    }    // save history too    var listNode = getQueryHistoryListNode(false);    if (!listNode) {        debug.print("cqExport: null listNode");    } else {        var historyQueries = listNode.childNodes;        var historyLength = historyQueries.length;        for (var i = 0; i < historyLength; i++) {            theQuery += '<' + g_cq_history_basename + '>'                // TODO xml-escape, instead?                + encodeURIComponent(historyQueries[i].firstChild.nodeValue)                + '</' + g_cq_history_basename + '>'                + "\n";        }    }    theQuery += '</' + g_cq_buffers_area_id + '>)'        + ', "exported ' + theUri + '"';    // TODO think about separating queries from worksheets,    // for storage purposes.    submitForm(theForm, theQuery, "text/html");    debug.print("cqExport: preserving selected database " + oldDatabase);} // cqExport
meta: 952	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/952/c2e7a157fb2c674a41925a5417c356a9c4ff1404/cq.js/buggy/cq.js