You are here

function taxonomy_xml_rdf_create_term in Taxonomy import/export via XML 7

Return a term as RDF-XML.

A sub-hook implementation of taxonomy_xml_{format}_create_term()

Parameters

int|object $term: Either a term object, or a term id

int $depth: How far currently recursed into the tree

int|null $max_depth: How far to recurse into this items children.

Return value

string an XML string.

See also

taxonomy_xml_export_term()

File

formats/rdf_format.inc, line 881

Code

function taxonomy_xml_rdf_create_term($term, $depth = -1, $max_depth = NULL) {
  $term = is_numeric($term) ? taxonomy_term_load($term) : $term;

  // Do I need to load in all extra data ? All taken core of in D7?
  if (empty($term)) {
    watchdog('taxonomy_xml', "NULL term loaded <pre>!data</pre>", array(
      '!data' => func_get_args(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  $domcontainer = taxonomy_xml_rdf_document();
  $dom = $domcontainer->ownerDocument;

  // Although we were only asked for one term,
  // child or parent terms may be mentioned when the entry is built.
  taxonomy_xml_rdf_add_terms($domcontainer, $term);
  $result = $dom
    ->savexml();

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