You are here

function taxonomy_xml_rdfs_export_term in Taxonomy import/export via XML 7

Return a single term as RDF. Header and all

File

./rdfs_format.inc, line 242

Code

function taxonomy_xml_rdfs_export_term($term, $depth = -1, $max_depth = NULL) {
  if (is_numeric($term)) {
    $term = taxonomy_term_load($term);
  }

  // Load in all extra data ? All taken core of in D7?
  $domcontainer = taxonomy_xml_rdf_document();
  $dom = $domcontainer->ownerDocument;
  taxonomy_xml_add_terms_as_rdf($domcontainer, $term);

  // Now start adding child terms.
  // Should recurse according to rules set elsewhere (taxonomy_server)
  // If taxonomy_server is not present, then use default recursion rule.
  // They are listed as siblings, not children of the ontology
  $tree = module_invoke('taxonomy', 'get_tree', $term->vid, $term->tid, $max_depth, $depth);
  taxonomy_xml_add_terms_as_rdf($domcontainer, $tree);
  $result = $dom
    ->savexml();

  // Minor layout tweak for readability
  $result = preg_replace('|(<[^<]*/[^>]*>)|', "\$1\n", $result);
  $result = preg_replace('|><|', ">\n<", $result);

  #dpm($result);
  print $result;
  exit;
}