return; 
SPARQL.Query = function(service, priority) {	//---------------	// private fields	var _conn = null;	var _service = service;	var _default_graphs = clone_obj(service.defaultGraphs()); // prevent future updates from affecting us	var _named_graphs = clone_obj(service.namedGraphs());	var _prefix_map = clone_obj(service.prefixes());	var _user_query = ''; // doesn't include auto-generated prefix declarations    var _method = service.method();	var _output = service.output();	var _priority = priority || 0;	var _request_headers = service.requestHeaders();	//------------------	// private functions	function _create_json(text) { 		if (!text)			return null;		// make sure this is safe JSON		// see: http://www.ietf.org/internet-drafts/draft-crockford-jsonorg-json-03.txt				// (1) strip out quoted strings		var no_strings = text.replace(/"(\\.|[^"\\])*"/g, '');		// (2) make sure that all the characters are explicitly part of the JSON grammar		// (in particular, note as discussed in the IETF submission, there are no assignments		//  or function invocations allowed by this reg. exp.)		var hasBadCharacter = /[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(no_strings);		// (3) evaluate the JSON string, returning its contents		if (!hasBadCharacter) {			try {				return eval('(' + text + ')');			} catch (e) {				return null;			}		}		return null; 	}			function clone_obj(o) { 		var o2 = o instanceof Array ? [] : {}; 		for(var x in o) {o2[x] = o[x];} 		return o2;	}	//----------------	// private methods	this._doCallback = function(cb, which, arg) {		//document.getElementById('log').innerHTML += "_doCallback ... <br>";		var user_data = "argument" in cb ? cb.argument : null;		if (which in cb) {			if (cb.scope) {				cb[which].apply(scope, [arg, user_data]);			} else { 				cb[which](arg, user_data); 			}		}	}		this._queryFailure = function(xhr, arg) {		SPARQL.statistics.failures++;		_service._markDone(this);		this._doCallback(arg.callback, 'failure', xhr /* just pass through the connection response object */);	};	this._querySuccess = function(xhr, arg) {		SPARQL.statistics.successes++;		_service._markDone(this);		this._doCallback(arg.callback, 'success', arg.transformer(			_output == 'json' ? _create_json(xhr.responseText) : xhr.responseText		));	};		function getXmlHttpRequest(url) {		// right now, this only does Firefox (Opera? Safari?)		return new XMLHttpRequest();	}		this._doQuery = function(queryString, callback, transformer) {		_user_query = queryString;		if (_service._canRun()) {			try {				if (_method != 'POST' && _method != 'GET')					throw("HTTP methods other than GET and POST are not supported.");							var url = _method == 'GET' ? this.queryUrl() : this.service().endpoint();				var xhr = getXmlHttpRequest(url);				var content = null;				try {					if (!document.domain || (url.slice(7, document.domain.length + 7) != document.domain && netscape && netscape.security && netscape.security.PrivilegeManager)) {						netscape.security.PrivilegeManager.enablePrivilege( "UniversalBrowserRead");						netscape.security.PrivilegeManager.enablePrivilege( "UniversalXPConnect"); 					}				} catch(e) {					alert("Cross-site requests prohibited. You will only be able to SPARQL the origin site: " + e);				}								xhr.open(_method, url, true /* async */);								// set the headers, including the content-type for POSTed queries				for (var header in this.requestHeaders())					xhr.setRequestHeader(header, this.requestHeaders()[header]);				if (_method == 'POST') {					xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');					content = this.queryParameters();				}					SPARQL.statistics.queries_sent++;				_service._markRunning(this);					var callbackData = {					scope:this, 					success: this._querySuccess, 					failure: this._queryFailure,					argument: {						transformer: transformer,						callback: callback					}				};								// I've seen some strange race-condition behavior (strange since normally				// JS is single-threaded, so synchronization conditions don't occur barring 				// reentrancy) with onreadystatechange. Instead, we poll asynchronously to				// determine when the request is done.				var token = window.setInterval(					function () {						if (xhr.readyState == 4) { // ready!							// clear this handler							window.clearInterval(token);							// we check the status to know which callback to call							if (xhr.status >= 200 && xhr.status < 300)								callbackData.success.apply(callbackData.scope, [xhr, callbackData.argument]);							else								callbackData.failure.apply(callbackData.scope, [xhr, callbackData.argument]);						}					},					200 /* maybe this should be customizable */				);								xhr.send(content);			} catch (e) {				alert("Error sending SPARQL query: " + e);			}		} else {			var self = this;			_service._queue(self, function() { self._doQuery(queryString, callback, transformer); }, _priority);		}	};		//----------	// accessors	this.request = function() { return _conn; };	this.service = function() { return _service; };	this.defaultGraphs = function() { return _default_graphs; };	this.namedGraphs = function() { return _named_graphs; };	this.prefixes = function() { return _prefix_map; };    this.method = function() { return _method; };    this.requestHeaders = function() { return _request_headers; };    /**     * Returns the SPARQL query represented by this object. The parameter, which can     * be omitted, determines whether or not auto-generated PREFIX clauses are included     * in the returned query string.     */	this.queryString = function(excludePrefixes) {		var preamble = '';		if (!excludePrefixes) {			for (var prefix in this.prefixes()) {				if(typeof(this.prefixes()[prefix]) != 'string') continue;				preamble += 'PREFIX ' + prefix + ': <' + this.prefixes()[prefix] + '> ';			}		}		return preamble + _user_query;	};	    /**     * Returns the HTTP query parameters to invoke this query. This includes entries for     * all of the default graphs, the named graphs, the SPARQL query itself, and an      * output parameter to specify JSON (or other) output is desired.     */	this.queryParameters = function () {		var urlQueryString = '';		var i;				// add default and named graphs to the protocol invocation		for (i = 0; i < this.defaultGraphs().length; i++) urlQueryString += 'default-graph-uri=' + escape(this.defaultGraphs()[i]) + '&';		for (i = 0; i < this.namedGraphs().length; i++) urlQueryString += 'named-graph-uri=' + escape(this.namedGraphs()[i]) + '&';				// specify JSON output (currently output= supported by latest Joseki) (or other output)		urlQueryString += 'output=' + _output + '&';		return urlQueryString + 'query=' + escape(this.queryString());	}	    /**     * Returns the HTTP GET URL to invoke this query. (Note that this returns a full HTTP GET URL      * even if this query is set to actually use POST.)     */	this.queryUrl = function() {		var url = this.service().endpoint() + '?';		return url + this.queryParameters();	};		//---------	// mutators	function _add_graphs(toAdd, arr) {		if (toAdd instanceof Array)			for (var i = 0; i < toAdd.length; i++) arr.push(toAdd[i]);		else			arr.push(toAdd);	}	this.addDefaultGraph = function(g) { _add_graphs(g, this.defaultGraphs()); };	this.addNamedGraph = function(g) { _add_graphs(g, this.namedGraphs()); };	this.setPrefix = function(p, u) { this.prefixes()[p] = u; };    this.setMethod = function(m) {        if (m != 'GET' && m != 'POST') throw("HTTP methods other than GET and POST are not supported.");        _method = m;    };	this.setRequestHeader = function(h, v) { _request_headers[h] = v; };		//---------------	// public methods	// use our varied transformations to create the various methods of actually issuing 	// queries	for (var query_form in SPARQL._query_transformations) {		// need the extra function to properly scope query_form (qf)		this[query_form] = (function(qf) {			return function(queryString, callback) {				this._doQuery(queryString, callback, SPARQL._query_transformations[qf]);			};		})(query_form);	}		//------------	// constructor		return this;}
125	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/125/536f356b67385ac89f4c6c7d9583fee96301d320/sparql.js/clean/webapps/joseki/snorql/sparql.js