You are here

function taxonomy_xml_rdf_process_dbpedia in Taxonomy import/export via XML 7

Special handling for dbpedia data.

eg http://dbpedia.org/page/Category:Rock_music_genres

When taking data from dbpedia, it does not list sub terms as 'narrower', it instead lists all the subterms individually, and tags them as having the parent term as 'broader'. This means the same thing, but the parent term does not know about its children. To support this, ensure that any resource (probably untyped) then has a 'broader' property matching a current term id gets tagged as being a child of it, and is present for being processed as a 'term'.

1 call to taxonomy_xml_rdf_process_dbpedia()
taxonomy_xml_rdf_parse in formats/rdf_format.inc
Read in RDF taxonomies and vocabularies. Create vocabs and terms as needed.

File

formats/rdf_format.inc, line 416

Code

function taxonomy_xml_rdf_process_dbpedia(&$resources_by_type, &$terms) {
  watchdog('taxonomy_xml', "Processing dbpedia special case", array(), WATCHDOG_INFO);
  foreach ($resources_by_type as $type => &$typedlist) {
    foreach ($typedlist as $guid => $resource) {
      if (isset($terms[$guid])) {

        // Already know this is a term.
        continue;
      }

      // Should canonicize predicates here?
      if (isset($resource->predicates[TAXONOMY_XML_SKOS_NS . 'broader'])) {

        // This is not a term, but is DOES have something else as a broader term
        // therefore it really is a term. (of unknown type).
        watchdog('taxonomy_xml', "Although not listed as a a term, %guid has something as a 'broader' parent. So it probably is a term after all. Adding it to the list", array(
          '%guid' => $guid,
        ), WATCHDOG_INFO);
        $terms[$guid] = $resource;
      }
    }
  }
  return $terms;
}