php rap example


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Trial</title>
  5. </head>
  6. <body>
  7. <?php
  8. define ( "RDFAPI_INCLUDE_DIR", "" );
  9. include (RDFAPI_INCLUDE_DIR . "RdfAPI.php");
  10.  
  11. $someDoc = new Resource ( "http://www.example.org/someDocument.html" );
  12. $creator = new Resource ( "http://www.purl.org/dc/elements/1.1/creator" );
  13.  
  14. $statement1 = new Statement ( $someDoc, $creator, new Literal ( "Radoslaw Oldakowski" ) );
  15.  
  16. $model1 = ModelFactory::getDefaultModel();
  17. $model1->add ( $statement1 );
  18. $model2 = ModelFactory::getDefaultModel();
  19. $model2->add( new Statement ( $someDoc, new Resource ( "http://www.example.org/myVocabulary/title" ), new Literal ( "RAP tutorial" ) ) );
  20. $model2->add( new Statement ( $someDoc, new Resource ( "http://www.example.org/myVocabulary/language" ), new Literal ( "English" ) ) );
  21.  
  22. $model1->addModel ( $model2 );
  23. echo "\$model1 contains " . $model1->size () . " statements";
  24. echo "<b>Output the MemModel as HTML table: </b><p>";
  25. $model1->writeAsHtmlTable ();
  26. echo "<b>Output the plain text serialization of the MemModel: </b><p>";
  27. echo $model1->toStringIncludingTriples ();
  28. echo "<b>Output the RDF/XML serialization of the MemModel: </b><p>";
  29. echo $model1->writeAsHtml ();
  30. ?>
  31. </body>

URL: https://sourceforge.net/projects/rdfapi-php/forums/forum/213511/topic/4005682/index/page/1

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.