1.1.1.0ds1 {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 1.5 1.5.0.* http://www.gophernet.org/does/not/exist EOT; $storage = new LibRDF_Storage(); $model = new LibRDF_Model($storage); $parser = new LibRDF_Parser(); $serializer = new LibRDF_Serializer("rdfxml-abbrev"); // set the mozilla namespace to something nicer $serializer->setNamespace(EM_BASE_URI, "em"); // load the initial RDF $model->loadStatementsFromString($parser, file_get_contents("source.rdf")); // The RDF file is headed by something that looks like: // // // // ... list of extensions and versions // // ... // find the blank target of urn:mozilla:... -> em:updates and find all the // the list items beneath it. $query = new LibRDF_Query("PREFIX rdf: <" . RDF_BASE_URI . "> " . "PREFIX em: <" . EM_BASE_URI . "> " . "SELECT ?blank ?predicate ?target WHERE { <" . RMANNOY_URI . "> em:updates ?blank . " . "?blank rdf:type rdf:Seq . " . "?blank ?predicate ?target . " . "FILTER REGEX(STR(?predicate), \"_[0-9]+$\") }", NULL, "sparql"); $results = $query->execute($model); // I'd like this to be one line, but PHP syntax kind of blows and only // allows variable names to be subscripted $blank = $results->current(); $blank = $blank["blank"]; // replace all of the _number predicates with li to trick the serializer // into using li. // firefox won't take the _1, _2 form that the serializer otherwise uses foreach ($results as $result) { $model->removeStatement(new LibRDF_Statement($result["blank"], $result["predicate"], $result["target"])); $model->addStatement(new LibRDF_Statement($result["blank"], new LibRDF_URINode(RDF_BASE_URI . "li"), $result["target"])); } // add to the Seq $model->addStatement(new LibRDF_Statement($blank, new LibRDF_URINode(RDF_BASE_URI . "li"), new LibRDF_URINode(RMANNOY_FORKED_URI))); // add the statements from $fork_rdf $model->loadStatementsFromString($parser, $fork_rdf); // output the RDF header("Content-type: application/rdf+xml"); echo $model->serializeStatements($serializer); ?>