RDF
[ class tree: RDF ] [ index: RDF ] [ all elements ]

Source for file test_ManipulateModelMemory.php

Documentation is available at test_ManipulateModelMemory.php

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4.     <title>Test Manipulate and Search RDF Model</title>
  5. </head>
  6. <body>
  7.  
  8. <?php 
  9. // Include RAP
  10. require_once 'RDF.php';
  11. require_once 'RDF/Model/Memory.php';
  12. // Filename of an RDF document
  13. $base "example1.rdf";
  14. // Create a new Model_Memory
  15. $model =new RDF_Model_Memory();
  16. // Load and parse document
  17. $model->load($base);
  18. // Output model as HTML table
  19. $model->writeAsHtmlTable();
  20. echo "<P>";
  21. // Ceate new statements and add them to the model
  22. $statement1 =RDF_Statement::factory(
  23.     RDF_Resource::factory('http://www.w3.org/Home/Lassila'),
  24.     RDF_Resource::factory('http://description.org/schema/Description'),
  25.     RDF_Literal::factory('Lassila\'s personal Homepage''en')
  26. );
  27.  
  28. $statement2 =RDF_Statement::factory(
  29.     RDF_Resource::factory('http://www.w3.org/Home/Lassila'),
  30.     RDF_Resource::factory('http://description.org/schema/Description'),
  31.     RDF_Literal::factory('de')
  32. );
  33.  
  34. $model->add($statement1);
  35. $model->add($statement2);
  36.  
  37. $model->writeAsHtmlTable();
  38. echo "<P>";
  39. // Build search index to speed up searches.
  40. $model->index();
  41. // Search model 1
  42. $homepage =RDF_Resource::factory("http://www.w3.org/Home/Lassila");
  43. $res $model->find($homepagenullnull);
  44.  
  45. $res->writeAsHtmlTable();
  46. echo "<P>";
  47. // Search model 2
  48. $description =RDF_Resource::factory("http://description.org/schema/Description");
  49. $statement $model->findFirstMatchingStatement($homepage$descriptionnull);
  50. // Check if something was found and output result
  51. if ($statement{
  52.     echo $statement->toString();
  53. else {
  54.     echo "Sorry, I didn't find anything.";
  55. echo "<P>";
  56. // Search model 3
  57. $res3 $model->findVocabulary("http://example.org/stuff/1.0/");
  58. $res3->writeAsHtmlTable();
  59. echo "<P>"
  60. // Write model as RDF
  61. $model->writeAsHtml();
  62. // Save model to file
  63. $model->saveAs("Output.rdf");
  64.  
  65. ?>
  66. </body>
  67. </html>

Documentation generated on Mon, 11 Mar 2019 15:39:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.