You are here

protected function EasyRdf_Parser_Rdfa::processUri in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php \EasyRdf_Parser_Rdfa::processUri()
3 calls to EasyRdf_Parser_Rdfa::processUri()
EasyRdf_Parser_Rdfa::getUriAttribute in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php
EasyRdf_Parser_Rdfa::processNode in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php
EasyRdf_Parser_Rdfa::processUriList in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Rdfa.php

File

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

Class

EasyRdf_Parser_Rdfa
Class to parse RDFa 1.1 with no external dependancies.

Code

protected function processUri($node, &$context, $value, $isProp = false) {
  if (preg_match('/^\\[(.*)\\]$/', $value, $matches)) {

    // Safe CURIE
    return $this
      ->expandCurie($node, $context, $matches[1]);
  }
  elseif (preg_match(self::TERM_REGEXP, $value) and $isProp) {
    $term = strtolower($value);
    if ($context['vocab']) {
      return $context['vocab'] . $value;
    }
    elseif (isset($context['terms'][$term])) {
      return $context['terms'][$term];
    }
  }
  elseif (substr($value, 0, 2) === '_:' and $isProp) {
    return null;
  }
  else {
    $uri = $this
      ->expandCurie($node, $context, $value);
    if ($uri) {
      return $uri;
    }
    else {
      $parsed = new EasyRdf_ParsedUri($value);
      if ($parsed
        ->isAbsolute()) {
        return $value;
      }
      elseif ($isProp) {

        // Properties can't be relative URIs
        return null;
      }
      elseif ($this->baseUri) {
        return $this->baseUri
          ->resolve($parsed);
      }
    }
  }
}