/** * @param object Resource $resource * @access private */ function collectNamespace($resource) { $namespace = RDFUtil::getNamespace($resource); if (!in_array($namespace, $this->m_namespaces) && $namespace != '') { $prefix = array_search($namespace, $this->m_defaultNamespaces); if ($prefix === FALSE) { $prefix = $this->getNextNamespacePrefix(); } $this->m_namespaces[$prefix] = $namespace; } }
/** * Get Node Type. * Used by RDFUtil::writeHTMLTable() * * @param object Node $node * @return object Resource * @access private */ function getNodeTypeName($node) { if (is_a($node, "BlankNode")) { return 'Blank Node: '; } elseif (is_a($node, 'Literal')) { return 'Literal: '; } else { if (RDFUtil::getNamespace($node) == RDF_NAMESPACE_URI || RDFUtil::getNamespace($node) == RDF_SCHEMA_URI || RDFUtil::getNamespace($node) == OWL_URI) { return 'RDF Node: '; } } return 'Resource: '; }
/** * Returns all tripels of a certain vocabulary. * $vocabulary is the namespace of the vocabulary inluding a # : / char at the end. * e.g. http://www.w3.org/2000/01/rdf-schema# * Returns an empty MemModel if nothing is found. * * @param string $vocabulary * @return object MemModel * @access public */ function findVocabulary($vocabulary) { if ($this->size() == 0) { return new MemModel(); } if ($vocabulary == NULL || $vocabulary == '') { return $this; } $res = new MemModel($this->getBaseURI()); if ($this->indexed == 0) { foreach ($this->indexArr[5] as $key => $value) { $pos = strpos($key, '#') + 1; if (substr($key, 0, $pos) == $vocabulary) { for ($i = 1; $i <= $value[0]; $i++) { $res->add($this->triples[$value[$i]]); } } } return $res; } else { // Import Package Utility include_once RDFAPI_INCLUDE_DIR . PACKAGE_UTILITY; foreach ($this->triples as $value) { if (RDFUtil::getNamespace($value->getPredicate()) == $vocabulary) { $res->add($value); } } return $res; } }