// Namespaces have to be registered before loading RDF data swipl.loadPrologCode(" \n\ :- rdf_db:rdf_register_ns(nmr, 'http://www.nmrshiftdb.org/onto#'). \n\ :- rdf_db:rdf_register_ns(xsd, 'http://www.w3.org/2001/XMLSchema#'). "); // Load RDF Data swipl.loadRDFToProlog("nmrshiftdata.rdf.xml"); // Load the Prolog method we want to use for querying swipl.loadPrologCode(" \n\ hasSpectrumWithPeakWithShift( Molecule, Shift ) :- \n\ rdf_db:rdf( Molecule, nmr:hasSpectrum, Spectrum ), \n\ rdf_db:rdf( Spectrum, nmr:hasPeak, Peak ), \n\ rdf_db:rdf( Peak, nmr:hasShift, literal(type(xsd:decimal, Shift)) ). "); // Query and output all molecules with shift = '42.2', limiting to 10 results var molecules = swipl.queryProlog( [ "hasSpectrumWithPeakWithShift", "10", "Molecules", "'42.2'" ] ); // Output results to console js.print(molecules);