*/ echo "

RAP Tutorial

"; // Include all RAP classes // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!! This has to reflect your own installation !!!!!!!!!!!!!!!!!!! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! define("RDFAPI_INCLUDE_DIR", "C:/Apache/rdf_api/api/"); include(RDFAPI_INCLUDE_DIR . "RdfAPI.php"); // Create a new MemModel and load the document $employees = ModelFactory::getDefaultModel(); $employees->load("employees.rdf"); // Show the input model echo "Show the RDF model to be queried:

"; $employees->writeAsHtmlTable(); echo "

"; // Query string: "find the full name of all employees" $query1 = ' SELECT ?fullName WHERE (?x, vcard:FN, ?fullName) USING vcard FOR '; // Execute the query $result1 = $employees->rdqlQuery($query1); // Display the query result as HTML table echo "
Query1: 'find the full name of all employees'. Output:

"; RdqlEngine::writeQueryResultAsHtmlTable($result1); // This will return no objects, but their string serialization instead $result2 = $employees->rdqlQuery($query1, FALSE); echo "

"; // Another query: "find the given name and age of all employees over 30" $query2 = ' SELECT ?givenName, ?age WHERE (?x, vcard:N, ?blank), (?blank, vcard:Given, ?givenName), (?x, v:age, ?age) AND ?age > 30 USING vcard FOR v FOR '; // Execute the query $result3 = $employees->rdqlQuery($query2); // Display the query result as HTML table echo "
Query2: 'find the given name and age of all employees over 30.' Output:

"; RdqlEngine::writeQueryResultAsHtmlTable($result3); echo "

"; // Yet another query: "find the private telephone number of the person // whose office number is '+1 111 2222 668' and return additionally his given name and age" $query3 = ' SELECT ?givenName ?age ?telNumberHome WHERE (?person vcard:N ?blank1) (?blank1 vcard:Given ?givenName) (?person v:age ?age) (?person vcard:TEL ?blank2) (?blank2 rdf:value ?telNumberHome) (?blank2 rdf:type vcard:home) (?person vcard:TEL ?blank3) (?blank3 rdf:value ?telNumberOffice) (?blank3 rdf:type vcard:work) AND ?telNumberOffice eq "+1 111 2222 668" USING vcard FOR v FOR '; // Execute the query $result4 = $employees->rdqlQuery($query3); // Display the query result as HTML table echo "
Query3: 'find the private telephone number of the person whose office number is '+1 111 2222 668' and return additionally his given name and age'. Output:

"; RdqlEngine::writeQueryResultAsHtmlTable($result4); echo "

"; // Next query: find the resources which represent employees whose family name starts with 'M' and return additionally the corresponding office email address $query4 = ' SELECT ?resource, ?email WHERE (?resource, vcard:N, ?blank1) (?blank1, vcard:Family, ?familyName) (?resource, vcard:EMAIL, ?blank2) (?blank2, rdf:value, ?email) (?blank2, rdf:type, vcard:work) AND ?familyName ~~ "/^M/" USING vcard FOR '; // Execute the query $result5 = $employees->rdqlQuery($query4); // Display the query result as HTML table echo "
Query4: 'find the resources which represent employees whose family name starts with \"M\" and return additionally the corresponding office email address'. Output:

"; RdqlEngine::writeQueryResultAsHtmlTable($result5); ?>