lib/main/js_sparql.js
function(h_subjects, b_raw) {

			// initiliaze output
			var s_out = '';

			// add slot for tail
			var s_tail = '';

			// newline + indent
			var _ = '\n\t'+(b_raw? '\t':'');

			// root nodes must be subjects
			for(var s_rs in h_subjects) {

				//
				var z_predicates = h_subjects[s_rs];

				// declaring optional block
				if(s_rs == '?') {

					// these are subjects actually
					var h_write = query_hash(z_predicates, true);
					s_out += _+'OPTIONAL {'+h_write.where+_+'}';
					s_tail += h_write.tail;
				}

				// regular query hash
				else {

					var s_rsi = rdf_var(s_rs);

					// this is subject
					s_out += _+s_rsi;

					// predicates are in hash
					if(typeof z_predicates == 'object') {

						// recurse
						var a_write = build_from_ph(z_predicates, _);
						s_out += a_write[0]+' .';
						s_tail += a_write[1];
					}
				}
			}

			var h_raw = {
				treated_vars: {subs:{},lists:{}},
				select: '',
				where: s_out,
				tail: s_tail,
				group: '',
				order: '',
				limit: '',
			};

			return (b_raw? h_raw: qb(h_raw));
		}
function(h_subjects, b_raw) {

			// initiliaze output
			var s_out = '';

			// add slot for tail
			var s_tail = '';

			// newline + indent
			var _ = '\n\t'+(b_raw? '\t':'');

			// root nodes must be subjects
			for(var s_rs in h_subjects) {

				//
				var z_predicates = h_subjects[s_rs];

				// declaring optional block
				if(s_rs == '?') {

					// these are subjects actually
					var h_write = query_hash(z_predicates, true);
					s_out += _+'OPTIONAL {'+h_write.where+_+'}';
					s_tail += h_write.tail;
				}

				// regular query hash
				else {

					var s_rsi = rdf_var(s_rs);

					// this is subject
					s_out += _+s_rsi;

					// predicates are in hash
					if(typeof z_predicates == 'object') {

						// recurse
						var a_write = build_from_ph(z_predicates, _);
						s_out += a_write[0]+' .';
						s_tail += a_write[1];
					}
				}
			}

			var h_raw = {
				treated_vars: {subs:{},lists:{}},
				select: '',
				where: s_out,
				tail: s_tail,
				group: '',
				order: '',
				limit: '',
			};

			return (b_raw? h_raw: qb(h_raw));
		}
function ( h_subjects , b_raw ) { // initiliaze output var s_out = '' ; // add slot for tail var s_tail = '' ; // newline + indent var _ = '\n\t' + ( b_raw ? '\t' : '' ) ; // root nodes must be subjects for ( var s_rs in h_subjects ) { // var z_predicates = h_subjects [ s_rs ] ; // declaring optional block if ( s_rs == '?' ) { // these are subjects actually var h_write = query_hash ( z_predicates , true ) ; s_out += _ + 'OPTIONAL {' + h_write . where + _ + '}' ; s_tail += h_write . tail ; } // regular query hash else { var s_rsi = rdf_var ( s_rs ) ; // this is subject s_out += _ + s_rsi ; // predicates are in hash if ( typeof z_predicates == 'object' ) { // recurse var a_write = build_from_ph ( z_predicates , _ ) ; s_out += a_write [ 0 ] + ' .' ; s_tail += a_write [ 1 ] ; } } } var h_raw = { treated_vars : { subs : { } , lists : { } } , select : '' , where : s_out , tail : s_tail , group : '' , order : '' , limit : '' , } ; return ( b_raw ? h_raw : qb ( h_raw ) ) ; }
constructs sparql query string from hash
constructs sparql query string from hash