protected function EasyRdf_Parser_Rdfa::expandCurie

1 call to EasyRdf_Parser_Rdfa::expandCurie()
EasyRdf_Parser_Rdfa::processUri in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php, line 211

Class

EasyRdf_Parser_Rdfa
Class to parse RDFa 1.1 with no external dependancies.

Code

protected function expandCurie($node, &$context, $value) {
  if (preg_match("/^(\\w*?):(.*)\$/", $value, $matches)) {
    list(, $prefix, $local) = $matches;
    $prefix = strtolower($prefix);
    if ($prefix === '_') {

      // It is a bnode
      return $this
        ->remapBnode(substr($value, 2));
    }
    elseif (empty($prefix) and $context['vocab']) {

      // Empty prefix
      return $context['vocab'] . $local;
    }
    elseif (isset($context['prefixes'][$prefix])) {
      return $context['prefixes'][$prefix] . $local;
    }
    elseif ($uri = $node
      ->lookupNamespaceURI($prefix)) {
      return $uri . $local;
    }
    elseif (!empty($prefix) and $uri = EasyRdf_Namespace::get($prefix)) {

      // Expand using well-known prefixes
      return $uri . $local;
    }
  }
}