Ejemplo n.º 1
0
 function MwRdfOutputXml($model)
 {
     global $wgOut, $_SERVER, $wgRdfNamespaces;
     $rdftype = wfNegotiateType(wfAcceptToPrefs($_SERVER['HTTP_ACCEPT']), wfAcceptToPrefs(MWRDF_XML_TYPE_PREFS));
     if (!$rdftype) {
         wfHttpError(406, "Not Acceptable", wfMsg("notacceptable"));
         return false;
     } else {
         $wgOut->disable();
         header("Content-type: {$rdftype}; charset=utf-8");
         $wgOut->sendCacheControl();
         # Make sure serializer is loaded
         require_once RDFAPI_INCLUDE_DIR . PACKAGE_SYNTAX_RDF;
         $ser = new RDFSerializer();
         $ser->configSortModel(true);
         $ser->configUseAttributes(false);
         $ser->configUseEntities(false);
         foreach ($wgRdfNamespaces as $key => $value) {
             $ser->addNamespacePrefix($key, $value);
         }
         print $ser->serialize($model);
         return true;
     }
 }
Ejemplo n.º 2
0
 if ($_POST['view_triple'] == "1") {
     echo "<BR><BR><h3>View input as HTML table:</h3><BR>";
     RDFUtil::writeHTMLTable($model);
     echo "<P>";
 }
 //serialize model to RDF with default configuration if checked in submitted form
 if ($_POST['serialize'] == '1') {
     // Create Serializer
     $ser = new RDFSerializer();
     $msg_string = '';
     if (isset($_POST['serial_attributes']) and $_POST['serial_attributes'] == '1') {
         $ser->configUseAttributes(TRUE);
         $msg_string .= 'Use Attributes ';
     }
     if (isset($_POST['serial_entities']) and $_POST['serial_entities'] == '1') {
         $ser->configUseEntities(TRUE);
         $msg_string .= 'Use XML Entities ';
     }
     if (isset($_POST['serial_wo_qnames']) and $_POST['serial_wo_qnames'] == '1') {
         $ser->configUseQnames(FALSE);
         $msg_string .= 'Without Qnames ';
     }
     $rdf =& $ser->serialize($model);
     echo "<p><BR><h3>Serialization of input model";
     if (isset($msg_string)) {
         echo " (Options: " . $msg_string . ")";
     }
     echo ":</h3>";
     echo_string_with_linenumbers($rdf);
 }
 // Show dump of the model including triples if submitted in form
Ejemplo n.º 3
0
<?php 
define("RDFAPI_INCLUDE_DIR", "./../api/");
include RDFAPI_INCLUDE_DIR . "RdfAPI.php";
// Filename of an RDf document
$base = "example1.rdf";
// Create a new MemModel
$model = new MemModel();
// Load and parse document
$model->load($base);
// Output model as HTML table
//$model->writeAsHtmlTable();
echo "<P>";
// Create Serializer and serialize model to RDF with default configuration
$ser = new RDFSerializer();
$rdf =& $ser->serialize($model);
echo "<p><textarea cols='110' rows='20'>" . $rdf . "</textarea>";
// Serialize model to RDF using attributes
$ser->configUseAttributes(TRUE);
$rdf =& $ser->serialize($model);
echo "<p><textarea cols='110' rows='20'>" . $rdf . "</textarea>";
$ser->configUseAttributes(FALSE);
// Serialize model to RDF using entities
$ser->configUseEntities(TRUE);
$rdf =& $ser->serialize($model);
echo "<p><textarea cols='110' rows='30'>" . $rdf . "</textarea>";
$ser->configUseEntities(FALSE);
?>

</body>
</html>