You are here

function taxonomy_xml_rdf_shortname in Taxonomy import/export via XML 6.2

Same name and namespace in other branches
  1. 5.2 rdf_format.inc \taxonomy_xml_rdf_shortname()
  2. 5 rdf_format.inc \taxonomy_xml_rdf_shortname()
  3. 6 rdf_format.inc \taxonomy_xml_rdf_shortname()

Return the shorthand label of a potentially long RDF URI

EG, for http://www.w3.org/1999/02/22-rdf-syntax-ns#Property return 'Property' ... for sanity

Also flatten LSIDs - which are used like URIs but just are NOT as useful

1 call to taxonomy_xml_rdf_shortname()
taxonomy_xml_convert_triples_to_sorted_objects in ./rdf_format.inc
Compile triple statements into information objects again.

File

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

Code

function taxonomy_xml_rdf_shortname($uri) {

  // For LSID simplification, flatten assorted RDF-LSID-Predicates (from any authority) into their simple name
  if (($lsid = taxonomy_xml_parse_lsid($uri)) && $lsid['namespace'] == 'predicates') {
    return $lsid['identifier'];
  }

  // If I recognised namespaces, I could use short ones. That would be fine.
  // But I don't want to start conflicting with rdf.modules ones.

  #if (function_exists('rdf_uri_to_qname')) {

  #  return rdf_uri_to_qname($uri);

  #}

  # yeah, by trimming namespaces and making guesses, now can't put them back in.

  # Needs revision.
  $parts = parse_url($uri);
  $shortname = !empty($parts['fragment']) ? $parts['fragment'] : (!empty($parts['query']) ? $parts['query'] : basename($parts['path']));

  // The proper method for guessing simple names is probably documented elsewhere.
  // ... this does the trick for now.
  return $shortname;
}