From: graha m. <gra...@gm...> - 2009-07-18 07:24:09
|
Hi.. I have created a form for the user to input the variable in order to query. The code as below: <?php echo " <html> <title> Test Query </title> <body> <form name=form method=post action=simplequeryprocess.php> <table> <tr> <td><h3> Insert the Person name: </h3> </td> </tr> <tr> <td> <input type=text name=personname size=70 maxlength=200> </td> </tr> </table> <table> <tr><td height=5 colspan=2></td></tr> <tr valign=center> <td align=right> <input TYPE=submit NAME=search VALUE='Search' class=forButton> <input TYPE=reset NAME=search VALUE=' Reset ' class=forButton> </td> </form> </tr> </table> </body> </html> "; ?> The following is the process file: <?php echo " <html> <title> Query Result </title> <body> "; // Include RAP define("RDFAPI_INCLUDE_DIR", "c:/www/rdfapi-php/api/"); include(RDFAPI_INCLUDE_DIR . "RdfAPI.php"); // Filename of an RDF document $base="simple.rdf"; // Create a new MemModel $model = ModelFactory::getDefaultModel(); // Load and parse document $model->load($base); //received data $personname=$_POST['personname']; $querystring = ' SELECT ?url ?PersonName ?DocumentName WHERE { ?url <http://www.semanticweb.org/ontologies/2009/5/simple.owl#has-name> ?PersonName . ?url <http://www.semanticweb.org/myontology.owl#has-document-name> ?DocumentName FILTER (?PersonName = \"${"personname"}\") }'; $result = $model->sparqlQuery($querystring); SPARQLEngine::writeQueryResultAsHtmlTable($result); echo "</body></html>"; ?> However, the \"${"personname"}\" did not carry any value and the sparql return result as no match. If I were to change the \"${"personname"}\" to a fix name such as "John", sparql will return the result. Can anyone tell me whether the way I am declaring the variable \"${"personname"}\" is correct or wrong?. Thanks. Grahamakmur |