You are here

function taxonomy_xml_get_namespaces in Taxonomy import/export via XML 6.2

Returns an array of RDF namespaces defined in modules that implement hook_rdf_namespaces().

Backport from D7 rdf_get_namespaces()

1 call to taxonomy_xml_get_namespaces()
taxonomy_xml_parse_curie in ./rdf_format.inc
Utility function to try and figure out what a given CURIE means

File

./rdf_format.inc, line 1321
Include routines for RDF parsing and taxonomy/term creation. @author dman http://coders.co.nz

Code

function taxonomy_xml_get_namespaces() {
  static $rdf_namespaces;
  if (!empty($rdf_namespaces)) {
    return $rdf_namespaces;
  }
  $rdf_namespaces = module_invoke_all('rdf_namespaces');

  // module_invoke_all() uses array_merge_recursive() which might return nested
  // arrays if several modules redefine the same prefix multiple times. We need
  // to ensure the array of namespaces is flat and only contains strings as
  // URIs.
  foreach ($rdf_namespaces as $prefix => $uri) {
    if (is_array($uri)) {
      if (count(array_unique($uri)) == 1) {

        // All namespaces declared for this prefix are the same, merge them all
        // into a single namespace.
        $rdf_namespaces[$prefix] = $uri[0];
      }
      else {

        // There are conflicting namespaces for this prefix, do not include
        // duplicates in order to avoid asserting any inaccurate RDF
        // statements.
        unset($rdf_namespaces[$prefix]);
      }
    }
  }
  return $rdf_namespaces;
}