// 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 if (isset($_POST['view_dump']) and $_POST['view_dump'] == '1') { echo "<BR><BR><h3>Dump of the model including triples</h3>"; echo_string_with_linenumbers($model->toStringIncludingTriples()); } ?> <center><a href="<?php echo $HTTP_SERVER_VARS['PHP_SELF'];
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; } }