/** Non implemented method (only defined) @author Frederick Giasson, Structured Dynamics LLC. */ public function pipeline_serialize_reification() { $rdf_reification = ""; switch ($this->conneg->getMime()) { case "application/rdf+n3": $xml = new ProcessorXML(); $xml->loadXML($this->pipeline_getResultset()); $subjects = $xml->getSubjects(); $bnodeCounter = 0; foreach ($subjects as $subject) { $predicates = $xml->getPredicates($subject); foreach ($predicates as $predicate) { $predicateType = $xml->getType($predicate, FALSE); $objects = $xml->getObjects($predicate); foreach ($objects as $object) { $reifies = $xml->getReificationStatements($object); $first = 0; foreach ($reifies as $reify) { if ($first == 0) { // $rdf_reification .= "_:bnode".$bnodeCounter." a rdf:Statement ;\n"; $rdf_reification .= "_:" . md5($xml->getURI($subject) . $predicateType . $xml->getURI($object)) . " a rdf:Statement ;\n"; $bnodeCounter++; $rdf_reification .= " rdf:subject <" . $xml->getURI($subject) . "> ;\n"; $rdf_reification .= " rdf:predicate <" . $predicateType . "> ;\n"; $rdf_reification .= " rdf:object <" . $xml->getURI($object) . "> ;\n"; } $first++; $reifyingProperty = $xml->getType($reify, FALSE); $rdf_reification .= " <{$reifyingProperty}> \"" . $xml->getValue($reify) . "\" ;\n"; } if ($first > 0) { $bnodeCounter++; $rdf_reification = substr($rdf_reification, 0, strlen($rdf_reification) - 2) . ".\n\n"; } } } } return $rdf_reification; break; case "application/rdf+xml": $xml = new ProcessorXML(); $xml->loadXML($this->pipeline_getResultset()); $subjects = $xml->getSubjects(); foreach ($subjects as $subject) { $predicates = $xml->getPredicates($subject); foreach ($predicates as $predicate) { $predicateType = $xml->getType($predicate, FALSE); $objects = $xml->getObjects($predicate); foreach ($objects as $object) { $reifies = $xml->getReificationStatements($object); $first = 0; foreach ($reifies as $reify) { if ($first == 0) { // $rdf_reification .= " <rdf:Statement>\n"; $rdf_reification .= " <rdf:Statement rdf:about=\"" . $this->xmlEncode(md5($xml->getURI($subject) . $predicateType . $xml->getURI($object))) . "\">\n"; $rdf_reification .= " <rdf:subject rdf:resource=\"" . $this->xmlEncode($xml->getURI($subject)) . "\" />\n"; $rdf_reification .= " <rdf:predicate rdf:resource=\"" . $this->xmlEncode($predicateType) . "\" />\n"; $rdf_reification .= " <rdf:object rdf:resource=\"" . $this->xmlEncode($xml->getURI($object)) . "\" />\n"; } $first++; $nsId = count($this->namespaces); $reifyingProperty = $xml->getType($reify, FALSE); $ns = $this->getNamespace($reifyingProperty); $ptNs = $ns[0]; $ptExtension = $ns[1]; if (!isset($this->namespaces[$ptNs])) { // Make sure the ID is not already existing. Increase the counter if it is the case. while (array_search("ns" . $nsId, $this->namespaces) !== FALSE) { $nsId++; } $this->namespaces[$ptNs] = "ns" . $nsId; } $rdf_reification .= " <" . $this->namespaces[$ptNs] . ":" . $ptExtension . ">" . $xml->getValue($reify) . "</" . $this->namespaces[$ptNs] . ":" . $ptExtension . ">\n"; } if ($first > 0) { $rdf_reification .= " </rdf:Statement> \n\n"; } } } } return $rdf_reification; break; } }