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

Source for file test_TraverseModel.php

Documentation is available at test_TraverseModel.php

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4.     <title>Test Traverse Model_Memory</title>
  5. </head>
  6. <body>
  7. <?php
  8.  
  9. require_once 'RDF.php';
  10. require_once 'RDF/Model/Memory.php';
  11.  
  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. // Get Iterator from model
  19. $it $model->getStatementIterator();
  20. // Traverse model and output statements
  21. while ($it->hasNext()) {
  22.     $statement $it->next();
  23.     echo "Statement number: " $it->getCurrentPosition("<BR>";
  24.     echo "Subject: " $statement->getLabelSubject("<BR>";
  25.     echo "Predicate: " $statement->getLabelPredicate("<BR>";
  26.     echo "Object: " $statement->getLabelObject("<P>";
  27. // Move to the last statement and print it
  28. $it->moveLast();
  29. $statement $it->current();
  30. // Traverse model backward and print statements
  31. echo $statement->toString("<BR>";
  32. while ($it->hasPrevious()) {
  33.     $statement $it->previous();
  34.     echo $statement->toString("<BR>";
  35. // Jump to statement 2 and print it
  36. $it->moveTo(2);
  37. $statement $it->current();
  38. echo $statement->toString("<BR>";
  39. ?>
  40. </body>
  41. </html>

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