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

Source for file custom_rdql_test.php

Documentation is available at custom_rdql_test.php

  1. <?php 
  2. // ----------------------------------------------------------------------------------
  3. // PHP Script: custom_rdql_test.php
  4. // ----------------------------------------------------------------------------------
  5. /*
  6.  * This is an online demo of RAP's RDQL engine.
  7.  * Input an RDQL query string and the engine will query the document
  8.  * specified in the source clause.
  9.  *
  10.  * @author Radoslaw Oldakowski <radol@gmx.de>
  11.  */
  12.  
  13. ?>
  14.  
  15. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  16. <HTML><HEAD><TITLE>RAP's RDQL-Engine online demo</TITLE>
  17. <META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
  18. <LINK href="phpdoc.css" rel=stylesheet type=text/css>
  19. </HEAD>
  20.  
  21. <BODY>
  22. <TABLE border=0 >
  23.   <TBODY>
  24.   <TR>
  25.     <TD align=left vAlign=top>
  26.       <DIV align=right><BR>
  27.         &nbsp;
  28.         <A href="http://www.w3.org/RDF/" target=_blank>
  29.           <IMG alt="RDF Logo" border=0 height=40 src="rdf_metadata_button.gif" width=95>
  30.         </A>
  31.         &nbsp;
  32.         <A href="http://www.php.net/" target=_blank>
  33.           <IMG alt="PHP Logo" border=0 height=64 src="php_logo.gif" width=120>
  34.         </A>
  35.       </DIV>
  36.       <H3>RDF API for PHP V0.8</H3>
  37.       <H1>RDQL-Engine Online Demo</H1><BR>
  38.       <P>This is an online demo of <A href="http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/index.html">
  39.          RAP - RDF API for PHP V0.8</A>.<br>
  40. <?php 
  41. // Test if the form is submitted or the query_string is too long
  42. if (!isset($_POST['submit']OR (strlen($_POST['query_string']> 1000)) {
  43.     // Show error message if the rdf is too long
  44.     if ((isset($_POST['submit']AND (strlen($_POST['query_string']> 1000))) {
  45.         echo "<center><a href='" $_SERVER['SCRIPT_NAME'"'><h2>Go back to input form.</h2></a></center>";
  46.         echo "<center><p class='rdql_comment'>We're sorry, but your RDQL query is bigger than the allowed size of 1000 characters</p></center>";
  47.     ;
  48.  
  49.     ?>
  50. <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];
  51.     ?>">
  52.       Paste an <a href="http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/rdql_grammar.htm">RDQL</a> query string into the text field below.
  53.       In the FROM clause you can indicate an URL or a path for local RDF document to be queried.
  54.       </P>
  55.       <H3>Please paste your RDQL query here:</H3>
  56.       <P><TEXTAREA cols=80 name=query_string rows=15>
  57. /* Find the name of the creator of <http://www.w3.org/Home/Lassila> */
  58. /* ---------------------------------------------------------------- */
  59.  
  60. SELECT ?Name
  61. /* --- Input file --- */
  62. FROM <Example1.rdf>
  63. WHERE (?x, <desc:Creator>, ?z)
  64.       (?z, <ex:Name>, ?Name)
  65. AND ?x eq <http://www.w3.org/Home/Lassila>
  66. USING desc FOR <http://description.org/schema/>
  67.       ex FOR <http://example.org/stuff/1.0/>
  68.  
  69.          </TEXTAREA> <BR>
  70.       </P>
  71.       <H3>Please choose the output format:</H3>
  72.           <TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
  73.             <TBODY>
  74.               <TR>
  75.                 <TD> <DIV align=center>
  76.                     <INPUT id="show_input" name="show_input"
  77.             type=checkbox value=1>
  78.                   </DIV></TD>
  79.                 <TD><STRONG>Show the source model</STRONG> (only if it contains
  80.                   fewer than 100 statements)</TD>
  81.               </TR>
  82.               <TR>
  83.                 <TD>&nbsp;</TD>
  84.                 <TD>&nbsp;</TD>
  85.               </TR>
  86.             </TBODY>
  87.           </TABLE>
  88.       <P><INPUT name=submit type=submit value="submit me!">
  89.       </P></FORM><BR>
  90. <?php
  91. else {
  92.     // Process the query if submitted
  93.     require_once 'RDF.php';
  94.     require_once 'RDF/Model/Memory.php';
  95.     require_once 'RDF/RDQL.php';
  96.  
  97.     echo "<center><a href='" $_SERVER['SCRIPT_NAME'"'>
  98.          <h2>Go back to input form.</h2></a></center>";
  99.  
  100.     if (isset($_POST['query_string'])) {
  101.         $queryString stripslashes($_POST['query_string'])
  102.         // Parse the query
  103.         $parser =new RDF_RDQL_Parser();
  104.         $parsed =$parser->parseQuery($queryString)
  105.         // If more than one source file provided show an error message
  106.         if (count($parsed['sources']> 1{
  107.             echo "<center><p class='rdql_comment'>We're sorry, but this Online Demo allows you to query only one document</p></center>";
  108.         
  109.         // Load the input model into memory
  110.         $Model_Memory =new RDF_Model_Memory();
  111.         $Model_Memory->load($parsed['sources'][0])
  112.         // Process the query
  113.         $engine =new RDF_RDQL_Engine_Memory();
  114.         $queryResult $engine->queryModel($Model_Memory$parsedtrue)
  115.         // Show the query string
  116.         echo "<br><h3>Your query: </h3>";
  117.         echo "<table width='100%' bgcolor=#e7e7ef><tr><td>";
  118.         echo "<p bgcolor='34556'><code>" nl2br(htmlspecialchars(stripslashes($_POST['query_string']))) "</code></p>";
  119.         echo "</td></tr></table><br>"
  120.         // Show query result
  121.         echo "<br><h3>Query result: </h3>";
  122.         $engine->writeQueryResultAsHtmlTable($queryResult)
  123.         // Show the input model if option chosen
  124.         if (isset($_POST['show_input']&& $_POST['show_input'== "1"{
  125.             echo "<br><br><h3>Source model: </h3>";
  126.             $Model_Memory->writeAsHtmlTable();
  127.         
  128.     
  129. echo "<br><br><br>";
  130.  
  131. ?>
  132.       
  133.       <H1>Feedback</H1>
  134.       <P></P>
  135.       <p>Please send bug reports and other comments to <a href="mailto:radol@gmx.de">Radek Oldakowski</a>.<br></p>
  136.     </TR>
  137.     </TBODY>
  138.    </TABLE>
  139.   </BODY>
  140.  </HTML>

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