You are here

protected function EasyRdf_Parser_Rdfa::expandCurie in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php \EasyRdf_Parser_Rdfa::expandCurie()
1 call to EasyRdf_Parser_Rdfa::expandCurie()
EasyRdf_Parser_Rdfa::processUri in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php, line 210

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;
    }
  }
}