diff --git a/arc2-2.2.4/.gitignore b/arc2-2.2.4/.gitignore new file mode 100755 index 0000000..e580259 --- /dev/null +++ b/arc2-2.2.4/.gitignore @@ -0,0 +1,4 @@ +*.DS_Store +plugins/* +triggers/* +tests/coverage/* diff --git a/arc2-2.2.4/ARC2.php b/arc2-2.2.4/ARC2.php new file mode 100755 index 0000000..6815ba6 --- /dev/null +++ b/arc2-2.2.4/ARC2.php @@ -0,0 +1,484 @@ + + * @package ARC2 + */ + +/* E_STRICT hack */ +if (function_exists('date_default_timezone_get')) { + date_default_timezone_set(@date_default_timezone_get()); +} + +class ARC2 { + + static function getVersion() { + return '2011-12-01'; + } + + /* */ + + static function getIncPath($f = '') { + $r = realpath(dirname(__FILE__)) . '/'; + $dirs = array( + 'plugin' => 'plugins', + 'trigger' => 'triggers', + 'store' => 'store', + 'serializer' => 'serializers', + 'extractor' => 'extractors', + 'sparqlscript' => 'sparqlscript', + 'parser' => 'parsers', + ); + foreach ($dirs as $k => $dir) { + if (preg_match('/' . $k . '/i', $f)) { + return $r . $dir . '/'; + } + } + return $r; + } + + static function getScriptURI() { + if (isset($_SERVER) && (isset($_SERVER['SERVER_NAME']) || isset($_SERVER['HTTP_HOST']))) { + $proto = preg_replace('/^([a-z]+)\/.*$/', '\\1', strtolower($_SERVER['SERVER_PROTOCOL'])); + $port = $_SERVER['SERVER_PORT']; + $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; + $script = $_SERVER['SCRIPT_NAME']; + /* https */ + if (($proto == 'http') && $port == 443) { + $proto = 'https'; + $port = 80; + } + return $proto . '://' . $server . ($port != 80 ? ':' . $port : '') . $script; + } + elseif (isset($_SERVER['SCRIPT_FILENAME'])) { + return 'file://' . realpath($_SERVER['SCRIPT_FILENAME']); + } + return 'http://localhost/unknown_path'; + } + + static function getRequestURI() { + if (isset($_SERVER) && isset($_SERVER['REQUEST_URI'])) { + return preg_replace('/^([a-z]+)\/.*$/', '\\1', strtolower($_SERVER['SERVER_PROTOCOL'])) . + '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']) . + ($_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '') . + $_SERVER['REQUEST_URI']; + } + return ARC2::getScriptURI(); + } + + static function inc($f, $path = '') { + $prefix = 'ARC2'; + if (preg_match('/^([^\_]+)\_(.*)$/', $f, $m)) { + $prefix = $m[1]; + $f = $m[2]; + } + $inc_path = $path ? $path : ARC2::getIncPath($f); + $path = $inc_path . $prefix . '_' . urlencode($f) . '.php'; + if (file_exists($path)) return include_once($path); + /* safe-mode hack */ + if (@include_once($path)) return 1; + /* try other path */ + if ($prefix != 'ARC2') { + $path = $inc_path . strtolower($prefix) . '/' . $prefix . '_' . urlencode($f) . '.php'; + if (file_exists($path)) return include_once($path); + /* safe-mode hack */ + if (@include_once($path)) return 1; + } + return 0; + } + + /* */ + + static function mtime(){ + return microtime(true); + } + + static function x($re, $v, $options = 'si') { + return preg_match("/^\s*" . $re . "(.*)$/" . $options, $v, $m) ? $m : false; + } + + /* */ + + static function getFormat($val, $mtype = '', $ext = '') { + ARC2::inc('getFormat'); + return ARC2_getFormat($val, $mtype, $ext); + } + + static function getPreferredFormat($default = 'plain') { + ARC2::inc('getPreferredFormat'); + return ARC2_getPreferredFormat($default); + } + + /* */ + + static function toUTF8($v) { + if (urlencode($v) === $v) return $v; + //if (utf8_decode($v) == $v) return $v; + $v = (strpos(utf8_decode(str_replace('?', '', $v)), '?') === false) ? utf8_decode($v) : $v; + /* custom hacks, mainly caused by bugs in PHP's json_decode */ + $mappings = array( + '%18' => '‘', + '%19' => '’', + '%1C' => '“', + '%1D' => '”', + '%1E' => '„', + '%10' => '‐', + '%12' => '−', + '%13' => '–', + '%14' => '—', + '%26' => '&', + ); + $froms = array_keys($mappings); + $tos = array_values($mappings); + foreach ($froms as $i => $from) $froms[$i] = urldecode($from); + $v = str_replace($froms, $tos, $v); + /* utf8 tweaks */ + return preg_replace_callback('/([\x00-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3}|[\xf8-\xfb][\x80-\xbf]{4}|[\xfc-\xfd][\x80-\xbf]{5}|[^\x00-\x7f])/', array('ARC2', 'getUTF8Char'), $v); + } + + static function getUTF8Char($v) { + $val = $v[1]; + if (strlen(trim($val)) === 1) return utf8_encode($val); + if (preg_match('/^([\x00-\x7f])(.+)/', $val, $m)) return $m[1] . ARC2::toUTF8($m[2]); + return $val; + } + + /* */ + + static function splitURI($v) { + /* the following namespaces may lead to conflated URIs, + * we have to set the split position manually + */ + if (strpos($v, 'www.w3.org')) { + $specials = array( + 'http://www.w3.org/XML/1998/namespace', + 'http://www.w3.org/2005/Atom', + 'http://www.w3.org/1999/xhtml', + ); + foreach ($specials as $ns) { + if (strpos($v, $ns) === 0) { + $local_part = substr($v, strlen($ns)); + if (!preg_match('/^[\/\#]/', $local_part)) { + return array($ns, $local_part); + } + } + } + } + /* auto-splitting on / or # */ + //$re = '^(.*?)([A-Z_a-z][-A-Z_a-z0-9.]*)$'; + if (preg_match('/^(.*[\/\#])([^\/\#]+)$/', $v, $m)) return array($m[1], $m[2]); + /* auto-splitting on last special char, e.g. urn:foo:bar */ + if (preg_match('/^(.*[\:\/])([^\:\/]+)$/', $v, $m)) return array($m[1], $m[2]); + return array($v, ''); + } + + /* */ + + static function getSimpleIndex($triples, $flatten_objects = 1, $vals = '') { + $r = array(); + foreach ($triples as $t) { + $skip_t = 0; + foreach (array('s', 'p', 'o') as $term) { + $$term = $t[$term]; + /* template var */ + if (isset($t[$term . '_type']) && ($t[$term . '_type'] == 'var')) { + $val = isset($vals[$$term]) ? $vals[$$term] : ''; + $skip_t = isset($vals[$$term]) ? $skip_t : 1; + $type = ''; + $type = !$type && isset($vals[$$term . ' type']) ? $vals[$$term . ' type'] : $type; + $type = !$type && preg_match('/^\_\:/', $val) ? 'bnode' : $type; + if ($term == 'o') { + $type = !$type && (preg_match('/\s/s', $val) || !preg_match('/\:/', $val)) ? 'literal' : $type; + $type = !$type && !preg_match('/[\/]/', $val) ? 'literal' : $type; + } + $type = !$type ? 'uri' : $type; + $t[$term . '_type'] = $type; + $$term = $val; + } + } + if ($skip_t) { + continue; + } + if (!isset($r[$s])) $r[$s] = array(); + if (!isset($r[$s][$p])) $r[$s][$p] = array(); + if ($flatten_objects) { + if (!in_array($o, $r[$s][$p])) $r[$s][$p][] = $o; + } + else { + $o = array('value' => $o); + foreach (array('lang', 'type', 'datatype') as $suffix) { + if (isset($t['o_' . $suffix]) && $t['o_' . $suffix]) { + $o[$suffix] = $t['o_' . $suffix]; + } + elseif (isset($t['o ' . $suffix]) && $t['o ' . $suffix]) { + $o[$suffix] = $t['o ' . $suffix]; + } + } + if (!in_array($o, $r[$s][$p])) { + $r[$s][$p][] = $o; + } + } + } + return $r; + } + + static function getTriplesFromIndex($index) { + $r = array(); + foreach ($index as $s => $ps) { + foreach ($ps as $p => $os) { + foreach ($os as $o) { + $r[] = array( + 's' => $s, + 'p' => $p, + 'o' => $o['value'], + 's_type' => preg_match('/^\_\:/', $s) ? 'bnode' : 'uri', + 'o_type' => $o['type'], + 'o_datatype' => isset($o['datatype']) ? $o['datatype'] : '', + 'o_lang' => isset($o['lang']) ? $o['lang'] : '', + ); + } + } + } + return $r; + } + + static function getMergedIndex() { + $r = array(); + foreach (func_get_args() as $index) { + foreach ($index as $s => $ps) { + if (!isset($r[$s])) $r[$s] = array(); + foreach ($ps as $p => $os) { + if (!isset($r[$s][$p])) $r[$s][$p] = array(); + foreach ($os as $o) { + if (!in_array($o, $r[$s][$p])) { + $r[$s][$p][] = $o; + } + } + } + } + } + return $r; + } + + static function getCleanedIndex() {/* removes triples from a given index */ + $indexes = func_get_args(); + $r = $indexes[0]; + for ($i = 1, $i_max = count($indexes); $i < $i_max; $i++) { + $index = $indexes[$i]; + foreach ($index as $s => $ps) { + if (!isset($r[$s])) continue; + foreach ($ps as $p => $os) { + if (!isset($r[$s][$p])) continue; + $r_os = $r[$s][$p]; + $new_os = array(); + foreach ($r_os as $r_o) { + $r_o_val = is_array($r_o) ? $r_o['value'] : $r_o; + $keep = 1; + foreach ($os as $o) { + $del_o_val = is_array($o) ? $o['value'] : $o; + if ($del_o_val == $r_o_val) { + $keep = 0; + break; + } + } + if ($keep) { + $new_os[] = $r_o; + } + } + if ($new_os) { + $r[$s][$p] = $new_os; + } + else { + unset($r[$s][$p]); + } + } + } + } + /* check r */ + $has_data = 0; + foreach ($r as $s => $ps) { + if ($ps) { + $has_data = 1; + break; + } + } + return $has_data ? $r : array(); + } + + /* */ + + static function getStructType($v) { + /* string */ + if (is_string($v)) return 'string'; + /* flat array, numeric keys */ + if (in_array(0, array_keys($v))) {/* numeric keys */ + /* simple array */ + if (!is_array($v[0])) return 'array'; + /* triples */ + //if (isset($v[0]) && isset($v[0]['s']) && isset($v[0]['p'])) return 'triples'; + if (in_array('p', array_keys($v[0]))) return 'triples'; + } + /* associative array */ + else { + /* index */ + foreach ($v as $s => $ps) { + if (!is_array($ps)) break; + foreach ($ps as $p => $os) { + if (!is_array($os) || !is_array($os[0])) break; + if (in_array('value', array_keys($os[0]))) return 'index'; + } + } + } + /* array */ + return 'array'; + } + + /* */ + + static function getComponent($name, $a = '', $caller = '') { + ARC2::inc($name); + $prefix = 'ARC2'; + if (preg_match('/^([^\_]+)\_(.+)$/', $name, $m)) { + $prefix = $m[1]; + $name = $m[2]; + } + $cls = $prefix . '_' . $name; + if (!$caller) $caller = new stdClass(); + return new $cls($a, $caller); + } + + /* graph */ + + static function getGraph($a = '') { + return ARC2::getComponent('Graph', $a); + } + + /* resource */ + + static function getResource($a = '') { + return ARC2::getComponent('Resource', $a); + } + + /* reader */ + + static function getReader($a = '') { + return ARC2::getComponent('Reader', $a); + } + + /* parsers */ + + static function getParser($prefix, $a = '') { + return ARC2::getComponent($prefix . 'Parser', $a); + } + + static function getRDFParser($a = '') { + return ARC2::getParser('RDF', $a); + } + + static function getRDFXMLParser($a = '') { + return ARC2::getParser('RDFXML', $a); + } + + static function getTurtleParser($a = '') { + return ARC2::getParser('Turtle', $a); + } + + static function getRSSParser($a = '') { + return ARC2::getParser('RSS', $a); + } + + static function getSemHTMLParser($a = '') { + return ARC2::getParser('SemHTML', $a); + } + + static function getSPARQLParser($a = '') { + return ARC2::getComponent('SPARQLParser', $a); + } + + static function getSPARQLPlusParser($a = '') { + return ARC2::getParser('SPARQLPlus', $a); + } + + static function getSPARQLXMLResultParser($a = '') { + return ARC2::getParser('SPARQLXMLResult', $a); + } + + static function getJSONParser($a = '') { + return ARC2::getParser('JSON', $a); + } + + static function getSGAJSONParser($a = '') { + return ARC2::getParser('SGAJSON', $a); + } + + static function getCBJSONParser($a = '') { + return ARC2::getParser('CBJSON', $a); + } + + static function getSPARQLScriptParser($a = '') { + return ARC2::getParser('SPARQLScript', $a); + } + + /* store */ + + static function getStore($a = '', $caller = '') { + return ARC2::getComponent('Store', $a, $caller); + } + + static function getStoreEndpoint($a = '', $caller = '') { + return ARC2::getComponent('StoreEndpoint', $a, $caller); + } + + static function getRemoteStore($a = '', $caller = '') { + return ARC2::getComponent('RemoteStore', $a, $caller); + } + + static function getMemStore($a = '') { + return ARC2::getComponent('MemStore', $a); + } + + /* serializers */ + + static function getSer($prefix, $a = '') { + return ARC2::getComponent($prefix . 'Serializer', $a); + } + + static function getTurtleSerializer($a = '') { + return ARC2::getSer('Turtle', $a); + } + + static function getRDFXMLSerializer($a = '') { + return ARC2::getSer('RDFXML', $a); + } + + static function getNTriplesSerializer($a = '') { + return ARC2::getSer('NTriples', $a); + } + + static function getRDFJSONSerializer($a = '') { + return ARC2::getSer('RDFJSON', $a); + } + + static function getPOSHRDFSerializer($a = '') {/* deprecated */ + return ARC2::getSer('POSHRDF', $a); + } + + static function getMicroRDFSerializer($a = '') { + return ARC2::getSer('MicroRDF', $a); + } + + static function getRSS10Serializer($a = '') { + return ARC2::getSer('RSS10', $a); + } + + /* sparqlscript */ + + static function getSPARQLScriptProcessor($a = '') { + return ARC2::getComponent('SPARQLScriptProcessor', $a); + } + + /* */ + +} diff --git a/arc2-2.2.4/ARC2_Class.php b/arc2-2.2.4/ARC2_Class.php new file mode 100755 index 0000000..aa558b2 --- /dev/null +++ b/arc2-2.2.4/ARC2_Class.php @@ -0,0 +1,533 @@ + + * @homepage + * @package ARC2 + */ + +class ARC2_Class { + + function __construct($a, &$caller) { + $this->a = is_array($a) ? $a : array(); + $this->caller = $caller; + $this->__init(); + } + + function __init() {/* base, time_limit */ + if (!$_POST && isset($GLOBALS['HTTP_RAW_POST_DATA'])) parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $_POST); /* php5 bug */ + $this->inc_path = ARC2::getIncPath(); + $this->ns_count = 0; + $rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->nsp = array($rdf => 'rdf'); + $this->used_ns = array($rdf); + $this->ns = array_merge(array('rdf' => $rdf), $this->v('ns', array(), $this->a)); + + $this->base = $this->v('base', ARC2::getRequestURI(), $this->a); + $this->errors = array(); + $this->warnings = array(); + $this->adjust_utf8 = $this->v('adjust_utf8', 0, $this->a); + $this->max_errors = $this->v('max_errors', 25, $this->a); + $this->has_pcre_unicode = @preg_match('/\pL/u', 'test');/* \pL = block/point which is a Letter */ + } + + /* */ + + function v($name, $default = false, $o = false) {/* value if set */ + if ($o === false) $o = $this; + if (is_array($o)) { + return isset($o[$name]) ? $o[$name] : $default; + } + return isset($o->$name) ? $o->$name : $default; + } + + function v1($name, $default = false, $o = false) {/* value if 1 (= not empty) */ + if ($o === false) $o = $this; + if (is_array($o)) { + return (isset($o[$name]) && $o[$name]) ? $o[$name] : $default; + } + return (isset($o->$name) && $o->$name) ? $o->$name : $default; + } + + function m($name, $a = false, $default = false, $o = false) {/* call method */ + if ($o === false) $o = $this; + return method_exists($o, $name) ? $o->$name($a) : $default; + } + + /* */ + + function camelCase($v, $lc_first = 0, $keep_boundaries = 0) { + $r = ucfirst($v); + while (preg_match('/^(.*)[^a-z0-9](.*)$/si', $r, $m)) { + /* don't fuse 2 upper-case chars */ + if ($keep_boundaries && $m[1]) { + $boundary = substr($m[1], -1); + if (strtoupper($boundary) == $boundary) $m[1] .= 'CAMELCASEBOUNDARY'; + } + $r = $m[1] . ucfirst($m[2]); + } + $r = str_replace('CAMELCASEBOUNDARY', '_', $r); + if ((strlen($r) > 1) && $lc_first && !preg_match('/[A-Z]/', $r[1])) $r = strtolower($r[0]) . substr($r, 1); + return $r; + } + + function deCamelCase($v, $uc_first = 0) { + $r = str_replace('_', ' ', $v); + $r = preg_replace('/([a-z0-9])([A-Z])/e', '"\\1 " . strtolower("\\2")', $r); + return $uc_first ? ucfirst($r) : $r; + } + + /** + * Tries to extract a somewhat human-readable label from a URI. + */ + + function extractTermLabel($uri, $loops = 0) { + list($ns, $r) = $this->splitURI($uri); + /* encode apostrophe + s */ + $r = str_replace('%27s', '_apostrophes_', $r); + /* normalize */ + $r = $this->deCamelCase($this->camelCase($r, 1, 1)); + /* decode apostrophe + s */ + $r = str_replace(' apostrophes ', "'s ", $r); + /* typical RDF non-info URI */ + if (($loops < 1) && preg_match('/^(self|it|this|me|id)$/i', $r)) { + return $this->extractTermLabel(preg_replace('/\#.+$/', '', $uri), $loops + 1); + } + /* trailing hash or slash */ + if ($uri && !$r && ($loops < 2)) { + return $this->extractTermLabel(preg_replace('/[\#\/]$/', '', $uri), $loops + 1); + } + /* a de-camel-cased URL (will look like "www example com") */ + if (preg_match('/^www (.+ [a-z]{2,4})$/', $r, $m)) { + return $this->getPrettyURL($uri); + } + return $r; + } + + /** + * Generates a less ugly in-your-face URL. + */ + + function getPrettyURL($r) { + $r = rtrim($r, '/'); + $r = preg_replace('/^https?\:\/\/(www\.)?/', '', $r); + return $r; + } + + /* */ + + function addError($v) { + if (!in_array($v, $this->errors)) { + $this->errors[] = $v; + } + if ($this->caller && method_exists($this->caller, 'addError')) { + $glue = strpos($v, ' in ') ? ' via ' : ' in '; + $this->caller->addError($v . $glue . get_class($this)); + } + if (count($this->errors) > $this->max_errors) { + die('Too many errors (limit: ' . $this->max_errors . '): ' . print_r($this->errors, 1)); + } + return false; + } + + function getErrors() { + return $this->errors; + } + + function getWarnings() { + return $this->warnings; + } + + function resetErrors() { + $this->errors = array(); + if ($this->caller && method_exists($this->caller, 'resetErrors')) { + $this->caller->resetErrors(); + } + } + + /* */ + + function splitURI($v) { + return ARC2::splitURI($v); + } + + /* */ + + function getPName($v, $connector = ':') { + /* is already a pname */ + $ns = $this->getPNameNamespace($v, $connector); + if ($ns) { + if (!in_array($ns, $this->used_ns)) $this->used_ns[] = $ns; + return $v; + } + /* new pname */ + $parts = $this->splitURI($v); + if ($parts) { + /* known prefix */ + foreach ($this->ns as $prefix => $ns) { + if ($parts[0] == $ns) { + if (!in_array($ns, $this->used_ns)) $this->used_ns[] = $ns; + return $prefix . $connector . $parts[1]; + } + } + /* new prefix */ + $prefix = $this->getPrefix($parts[0]); + return $prefix . $connector . $parts[1]; + } + return $v; + } + + function getPNameNamespace($v, $connector = ':') { + $re = '/^([a-z0-9\_\-]+)\:([a-z0-9\_\-\.\%]+)$/i'; + if ($connector != ':') { + $connectors = array('\:', '\-', '\_', '\.'); + $chars = join('', array_diff($connectors, array($connector))); + $re = '/^([a-z0-9' . $chars . ']+)\\' . $connector . '([a-z0-9\_\-\.\%]+)$/i'; + } + if (!preg_match($re, $v, $m)) return 0; + if (!isset($this->ns[$m[1]])) return 0; + return $this->ns[$m[1]]; + } + + function setPrefix($prefix, $ns) { + $this->ns[$prefix] = $ns; + $this->nsp[$ns] = $prefix; + return $this; + } + + function getPrefix($ns) { + if (!isset($this->nsp[$ns])) { + $this->ns['ns' . $this->ns_count] = $ns; + $this->nsp[$ns] = 'ns' . $this->ns_count; + $this->ns_count++; + } + if (!in_array($ns, $this->used_ns)) $this->used_ns[] = $ns; + return $this->nsp[$ns]; + } + + function expandPName($v, $connector = ':') { + $re = '/^([a-z0-9\_\-]+)\:([a-z0-9\_\-\.\%]+)$/i'; + if ($connector != ':') { + $connectors = array(':', '-', '_', '.'); + $chars = '\\' . join('\\', array_diff($connectors, array($connector))); + $re = '/^([a-z0-9' . $chars . ']+)\\' . $connector . '([a-z0-9\_\-\.\%]+)$/Ui'; + } + if (preg_match($re, $v, $m) && isset($this->ns[$m[1]])) { + return $this->ns[$m[1]] . $m[2]; + } + return $v; + } + + function expandPNames($index) { + $r = array(); + foreach ($index as $s => $ps) { + $s = $this->expandPName($s); + $r[$s] = array(); + foreach ($ps as $p => $os) { + $p = $this->expandPName($p); + if (!is_array($os)) $os = array($os); + foreach ($os as $i => $o) { + if (!is_array($o)) { + $o_val = $this->expandPName($o); + $o_type = preg_match('/^[a-z]+\:[^\s\<\>]+$/si', $o_val) ? 'uri' : 'literal'; + $o = array('value' => $o_val, 'type' => $o_type); + } + $os[$i] = $o; + } + $r[$s][$p] = $os; + } + } + return $r; + } + + /* */ + + function calcURI($path, $base = "") { + /* quick check */ + if (preg_match("/^[a-z0-9\_]+\:/i", $path)) {/* abs path or bnode */ + return $path; + } + if (preg_match('/^\$\{.*\}/', $path)) {/* placeholder, assume abs URI */ + return $path; + } + if (preg_match("/^\/\//", $path)) {/* net path, assume http */ + return 'http:' . $path; + } + /* other URIs */ + $base = $base ? $base : $this->base; + $base = preg_replace('/\#.*$/', '', $base); + if ($path === true) {/* empty (but valid) URIref via turtle parser: <> */ + return $base; + } + $path = preg_replace("/^\.\//", '', $path); + $root = preg_match('/(^[a-z0-9]+\:[\/]{1,3}[^\/]+)[\/|$]/i', $base, $m) ? $m[1] : $base; /* w/o trailing slash */ + $base .= ($base == $root) ? '/' : ''; + if (preg_match('/^\//', $path)) {/* leading slash */ + return $root . $path; + } + if (!$path) { + return $base; + } + if (preg_match('/^([\#\?])/', $path, $m)) { + return preg_replace('/\\' .$m[1]. '.*$/', '', $base) . $path; + } + if (preg_match('/^(\&)(.*)$/', $path, $m)) {/* not perfect yet */ + return preg_match('/\?/', $base) ? $base . $m[1] . $m[2] : $base . '?' . $m[2]; + } + if (preg_match("/^[a-z0-9]+\:/i", $path)) {/* abs path */ + return $path; + } + /* rel path: remove stuff after last slash */ + $base = substr($base, 0, strrpos($base, '/')+1); + /* resolve ../ */ + while (preg_match('/^(\.\.\/)(.*)$/', $path, $m)) { + $path = $m[2]; + $base = ($base == $root.'/') ? $base : preg_replace('/^(.*\/)[^\/]+\/$/', '\\1', $base); + } + return $base . $path; + } + + /* */ + + function calcBase($path) { + $r = $path; + $r = preg_replace('/\#.*$/', '', $r);/* remove hash */ + $r = preg_replace('/^\/\//', 'http://', $r);/* net path (//), assume http */ + if (preg_match('/^[a-z0-9]+\:/', $r)) {/* scheme, abs path */ + while (preg_match('/^(.+\/)(\.\.\/.*)$/U', $r, $m)) { + $r = $this->calcURI($m[1], $m[2]); + } + return $r; + } + return 'file://' . realpath($r);/* real path */ + } + + /* */ + + function getResource($uri, $store_or_props = '') { + $res = ARC2::getResource($this->a); + $res->setURI($uri); + if (is_array($store_or_props)) { + $res->setProps($store_or_props); + } + else { + $res->setStore($store_or_props); + } + return $res; + } + + function toIndex($v) { + if (is_array($v)) { + if (isset($v[0]) && isset($v[0]['s'])) return ARC2::getSimpleIndex($v, 0); + return $v; + } + $parser = ARC2::getRDFParser($this->a); + if ($v && !preg_match('/\s/', $v)) {/* assume graph URI */ + $parser->parse($v); + } + else { + $parser->parse('', $v); + } + return $parser->getSimpleIndex(0); + } + + function toTriples($v) { + if (is_array($v)) { + if (isset($v[0]) && isset($v[0]['s'])) return $v; + return ARC2::getTriplesFromIndex($v); + } + $parser = ARC2::getRDFParser($this->a); + if ($v && !preg_match('/\s/', $v)) {/* assume graph URI */ + $parser->parse($v); + } + else { + $parser->parse('', $v); + } + return $parser->getTriples(); + } + + /* */ + + function toNTriples($v, $ns = '', $raw = 0) { + ARC2::inc('NTriplesSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_NTriplesSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return (isset($v[0]) && isset($v[0]['s'])) ? $ser->getSerializedTriples($v, $raw) : $ser->getSerializedIndex($v, $raw); + } + + function toTurtle($v, $ns = '', $raw = 0) { + ARC2::inc('TurtleSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_TurtleSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return (isset($v[0]) && isset($v[0]['s'])) ? $ser->getSerializedTriples($v, $raw) : $ser->getSerializedIndex($v, $raw); + } + + function toRDFXML($v, $ns = '', $raw = 0) { + ARC2::inc('RDFXMLSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_RDFXMLSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return (isset($v[0]) && isset($v[0]['s'])) ? $ser->getSerializedTriples($v, $raw) : $ser->getSerializedIndex($v, $raw); + } + + function toRDFJSON($v, $ns = '') { + ARC2::inc('RDFJSONSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_RDFJSONSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return (isset($v[0]) && isset($v[0]['s'])) ? $ser->getSerializedTriples($v) : $ser->getSerializedIndex($v); + } + + function toRSS10($v, $ns = '') { + ARC2::inc('RSS10Serializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_RSS10Serializer(array_merge($this->a, array('ns' => $ns)), $this); + return (isset($v[0]) && isset($v[0]['s'])) ? $ser->getSerializedTriples($v) : $ser->getSerializedIndex($v); + } + + function toLegacyXML($v, $ns = '') { + ARC2::inc('LegacyXMLSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_LegacyXMLSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return $ser->getSerializedArray($v); + } + + function toLegacyJSON($v, $ns = '') { + ARC2::inc('LegacyJSONSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_LegacyJSONSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return $ser->getSerializedArray($v); + } + + function toLegacyHTML($v, $ns = '') { + ARC2::inc('LegacyHTMLSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $ser = new ARC2_LegacyHTMLSerializer(array_merge($this->a, array('ns' => $ns)), $this); + return $ser->getSerializedArray($v); + } + + function toHTML($v, $ns = '', $label_store = '') { + ARC2::inc('MicroRDFSerializer'); + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $conf = array_merge($this->a, array('ns' => $ns)); + if ($label_store) $conf['label_store'] = $label_store; + $ser = new ARC2_MicroRDFSerializer($conf, $this); + return (isset($v[0]) && isset($v[0]['s'])) ? $ser->getSerializedTriples($v) : $ser->getSerializedIndex($v); + } + + /* */ + + function getFilledTemplate($t, $vals, $g = '') { + $parser = ARC2::getTurtleParser(); + $parser->parse($g, $this->getTurtleHead() . $t); + return $parser->getSimpleIndex(0, $vals); + } + + function getTurtleHead() { + $r = ''; + $ns = $this->v('ns', array(), $this->a); + foreach ($ns as $k => $v) { + $r .= "@prefix " . $k . ": <" .$v. "> .\n"; + } + return $r; + } + + function completeQuery($q, $ns = '') { + if (!$ns) $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $added_prefixes = array(); + $prologue = ''; + foreach ($ns as $k => $v) { + $k = rtrim($k, ':'); + if (in_array($k, $added_prefixes)) continue; + if (preg_match('/(^|\s)' . $k . ':/s', $q) && !preg_match('/PREFIX\s+' . $k . '\:/is', $q)) { + $prologue .= "\n" . 'PREFIX ' . $k . ': <' . $v . '>'; + } + $added_prefixes[] = $k; + } + return $prologue . "\n" . $q; + } + + /* */ + + function toUTF8($str) { + return $this->adjust_utf8 ? ARC2::toUTF8($str) : $str; + } + + function toDataURI($str) { + return 'data:text/plain;charset=utf-8,' . rawurlencode($str); + } + + function fromDataURI($str) { + return str_replace('data:text/plain;charset=utf-8,', '', rawurldecode($str)); + } + + /* prevent SQL injections via SPARQL REGEX */ + + function checkRegex($str) { + return addslashes($str); // @@todo extend + } + + /* Microdata methods */ + + function getMicrodataAttrs($id, $type = '') { + $type = $type ? $this->expandPName($type) : $this->expandPName('owl:Thing'); + return 'itemscope="" itemtype="' . htmlspecialchars($type) . '" itemid="' . htmlspecialchars($id) . '"'; + } + + function mdAttrs($id, $type = '') { + return $this->getMicrodataAttrs($id, $type); + } + + /* central DB query hook */ + + function queryDB($sql, $con, $log_errors = 0) { + $t1 = ARC2::mtime(); + $r = mysql_query($sql, $con); + if (0) { + $t2 = ARC2::mtime() - $t1; + $call_obj = $this; + $call_path = ''; + while ($call_obj) { + $call_path = get_class($call_obj) . ' / ' . $call_path; + $call_obj = isset($call_obj->caller) ? $call_obj->caller : false; + } + echo "\n" . $call_path . " needed " . $t2 . ' secs for ' . str_replace("\n" , ' ', $sql);; + } + if ($log_errors && ($er = mysql_error($con))) $this->addError($er); + return $r; + } + + /** + * Shortcut method to create an RDF/XML backup dump from an RDF Store object. + */ + function backupStoreData($store, $target_path, $offset = 0) { + $limit = 10; + $q = ' + SELECT DISTINCT ?s WHERE { + ?s ?p ?o . + } + ORDER BY ?s + LIMIT ' . $limit . ' + ' . ($offset ? 'OFFSET ' . $offset : '') . ' + '; + $rows = $store->query($q, 'rows'); + $tc = count($rows); + $full_tc = $tc + $offset; + $mode = $offset ? 'ab' : 'wb'; + $fp = fopen($target_path, $mode); + foreach ($rows as $row) { + $index = $store->query('DESCRIBE <' . $row['s'] . '>', 'raw'); + if ($index) { + $doc = $this->toRDFXML($index); + fwrite($fp, $doc . "\n\n"); + } + } + fclose($fp); + if ($tc == 10) { + set_time_limit(300); + $this->backupStoreData($store, $target_path, $offset + $limit); + } + return $full_tc; + } + +} diff --git a/arc2-2.2.4/ARC2_Graph.php b/arc2-2.2.4/ARC2_Graph.php new file mode 100755 index 0000000..6e41931 --- /dev/null +++ b/arc2-2.2.4/ARC2_Graph.php @@ -0,0 +1,178 @@ + + * @license W3C Software License + * @homepage + * @package ARC2 +*/ + +ARC2::inc('Class'); + +class ARC2_Graph extends ARC2_Class { + + protected $index; + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->index = array(); + } + + function setIndex($index) { + $this->index = $index; + return $this; + } + + function getIndex() { + return $this->index; + } + + function addIndex($index) { + $this->index = ARC2::getMergedIndex($this->index, $index); + return $this; + } + + function addGraph($graph) { + // namespaces + foreach ($graph->ns as $prefix => $ns) { + $this->setPrefix($prefix, $ns); + } + // index + $this->addIndex($graph->getIndex()); + return $this; + } + + function addRdf($data, $format = null) { + if ($format == 'json') { + return $this->addIndex(json_decode($data, true)); + } + else {// parse any other rdf format + return $this->addIndex($this->toIndex($data)); + } + } + + function hasSubject($s) { + return isset($this->index[$s]); + } + + function hasTriple($s, $p, $o) { + if (!is_array($o)) { + return $this->hasLiteralTriple($s, $p, $o) || $this->hasLinkTriple($s, $p, $o); + } + if (!isset($this->index[$s])) return false; + $p = $this->expandPName($p); + if (!isset($this->index[$s][$p])) return false; + return in_array($o, $this->index[$s][$p]); + } + + function hasLiteralTriple($s, $p, $o) { + if (!isset($this->index[$s])) return false; + $p = $this->expandPName($p); + if (!isset($this->index[$s][$p])) return false; + $os = $this->getObjects($s, $p, false); + foreach ($os as $object) { + if ($object['value'] == $o && $object['type'] == 'literal') { + return true; + } + } + return false; + } + + function hasLinkTriple($s, $p, $o) { + if (!isset($this->index[$s])) return false; + $p = $this->expandPName($p); + if (!isset($this->index[$s][$p])) return false; + $os = $this->getObjects($s, $p, false); + foreach ($os as $object) { + if ($object['value'] == $o && ($object['type'] == 'uri' || $object['type'] == 'bnode')) { + return true; + } + } + return false; + } + + function addTriple($s, $p, $o, $oType = 'literal') { + $p = $this->expandPName($p); + if (!is_array($o)) $o = array('value' => $o, 'type' => $oType); + if ($this->hasTriple($s, $p, $o)) return; + if (!isset($this->index[$s])) $this->index[$s] = array(); + if (!isset($this->index[$s][$p])) $this->index[$s][$p] = array(); + $this->index[$s][$p][] = $o; + return $this; + } + + function getSubjects($p = null, $o = null) { + if (!$p && !$o) return array_keys($this->index); + $result = array(); + foreach ($this->index as $s => $ps) { + foreach ($ps as $predicate => $os) { + if ($p && $predicate != $p) continue; + foreach ($os as $object) { + if (!$o) { + $result[] = $s; + break; + } + else if (is_array($o) && $object == $o) { + $result[] = $s; + break; + } + else if ($o && $object['value'] == $o) { + $result[] = $s; + break; + } + } + } + } + return array_unique($result); + } + + function getPredicates($s = null) { + $result = array(); + $index = $s ? (array($s => isset($this->index[$s]) ? $this->index[$s] : array())) : $this->index; + foreach ($index as $subject => $ps) { + if ($s && $s != $subject) continue; + $result = array_merge($result, array_keys($ps)); + } + return array_unique($result); + } + + function getObjects($s, $p, $plain = false) { + if (!isset($this->index[$s])) return array(); + $p = $this->expandPName($p); + if (!isset($this->index[$s][$p])) return array(); + $os = $this->index[$s][$p]; + if ($plain) { + array_walk($os, function(&$o) { + $o = $o['value']; + }); + } + return $os; + } + + function getObject($s, $p, $plain = false, $default = null) { + $os = $this->getObjects($s, $p, $plain); + return empty($os) ? $default : $os[0]; + } + + function getNTriples() { + return parent::toNTriples($this->index, $this->ns); + } + + function getTurtle() { + return parent::toTurtle($this->index, $this->ns); + } + + function getRDFXML() { + return parent::toRDFXML($this->index, $this->ns); + } + + function getJSON() { + return json_encode($this->index); + } + +} diff --git a/arc2-2.2.4/ARC2_Reader.php b/arc2-2.2.4/ARC2_Reader.php new file mode 100755 index 0000000..c5ed492 --- /dev/null +++ b/arc2-2.2.4/ARC2_Reader.php @@ -0,0 +1,420 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_Reader extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* inc_path, proxy_host, proxy_port, proxy_skip, http_accept_header, http_user_agent_header, max_redirects */ + parent::__init(); + $this->http_method = $this->v('http_method', 'GET', $this->a); + $this->message_body = $this->v('message_body', '', $this->a);; + $this->http_accept_header = $this->v('http_accept_header', 'Accept: application/rdf+xml; q=0.9, text/turtle; q=0.8, */*; q=0.1', $this->a); + $this->http_user_agent_header = $this->v('http_user_agent_header', 'User-Agent: ARC Reader (http://arc.semsol.org/)', $this->a); + $this->http_custom_headers = $this->v('http_custom_headers', '', $this->a); + $this->max_redirects = $this->v('max_redirects', 3, $this->a); + $this->format = $this->v('format', false, $this->a); + $this->redirects = array(); + $this->stream_id = ''; + $this->timeout = $this->v('reader_timeout', 30, $this->a); + $this->response_headers = array(); + $this->digest_auth = 0; + $this->auth_infos = $this->v('reader_auth_infos', array(), $this->a); + } + + /* */ + + function setHTTPMethod($v) { + $this->http_method = $v; + } + + function setMessageBody($v) { + $this->message_body = $v; + } + + function setAcceptHeader($v) { + $this->http_accept_header = $v; + } + + function setCustomHeaders($v) { + $this->http_custom_headers = $v; + } + + function addCustomHeaders($v) { + if ($this->http_custom_headers) $this->http_custom_headers .= "\r\n"; + $this->http_custom_headers .= $v; + } + + /* */ + + function activate($path, $data = '', $ping_only = 0, $timeout = 0) { + $this->setCredentials($path); + $this->ping_only = $ping_only; + if ($timeout) $this->timeout = $timeout; + $id = md5($path . ' ' . $data); + if ($this->stream_id != $id) { + $this->stream_id = $id; + /* data uri? */ + if (!$data && preg_match('/^data\:([^\,]+)\,(.*)$/', $path, $m)) { + $path = ''; + $data = preg_match('/base64/', $m[1]) ? base64_decode($m[2]) : rawurldecode($m[2]); + } + $this->base = $this->calcBase($path); + $this->uri = $this->calcURI($path, $this->base); + $this->stream = ($data) ? $this->getDataStream($data) : $this->getSocketStream($this->base, $ping_only); + if ($this->stream && !$this->ping_only) { + $this->getFormat(); + } + } + } + + /* + * HTTP Basic/Digest + Proxy authorization can be defined in the + * arc_reader_credentials config setting: + + 'arc_reader_credentials' => array( + 'http://basic.example.com/' => 'user:pass', // shortcut for type=basic + 'http://digest.example.com/' => 'user::pass', // shortcut for type=digest + 'http://proxy.example.com/' => array('type' => 'basic', 'proxy', 'user' => 'user', 'pass' => 'pass'), + ), + + */ + + function setCredentials($url) { + if (!$creds = $this->v('arc_reader_credentials', array(), $this->a)) return 0; + foreach ($creds as $pattern => $creds) { + /* digest shortcut (user::pass) */ + if (!is_array($creds) && preg_match('/^(.+)\:\:(.+)$/', $creds, $m)) { + $creds = array('type' => 'digest', 'user' => $m[1], 'pass' => $m[2]); + } + /* basic shortcut (user:pass) */ + if (!is_array($creds) && preg_match('/^(.+)\:(.+)$/', $creds, $m)) { + $creds = array('type' => 'basic', 'user' => $m[1], 'pass' => $m[2]); + } + if (!is_array($creds)) return 0; + $regex = '/' . preg_replace('/([\:\/\.\?])/', '\\\\\1', $pattern) . '/'; + if (!preg_match($regex, $url)) continue; + $mthd = 'set' . $this->camelCase($creds['type']) . 'AuthCredentials'; + if (method_exists($this, $mthd)) $this->$mthd($creds, $url); + } + } + + function setBasicAuthCredentials($creds) { + $auth = 'Basic ' . base64_encode($creds['user'] . ':' . $creds['pass']); + $h = in_array('proxy', $creds) ? 'Proxy-Authorization' : 'Authorization'; + $this->addCustomHeaders($h . ': ' . $auth); + //echo $h . ': ' . $auth . print_r($creds, 1); + } + + function setDigestAuthCredentials($creds, $url) { + $path = $this->v1('path', '/', parse_url($url)); + $auth = ''; + $hs = $this->getResponseHeaders(); + /* initial 401 */ + $h = $this->v('www-authenticate', '', $hs); + if ($h && preg_match('/Digest/i', $h)) { + $auth = 'Digest '; + /* Digest realm="$realm", nonce="$nonce", qop="auth", opaque="$opaque" */ + $ks = array('realm', 'nonce', 'opaque');/* skipping qop, assuming "auth" */ + foreach ($ks as $i => $k) { + $$k = preg_match('/' . $k . '=\"?([^\"]+)\"?/i', $h, $m) ? $m[1] : ''; + $auth .= ($i ? ', ' : '') . $k . '="' . $$k . '"'; + $this->auth_infos[$k] = $$k; + } + $this->auth_infos['auth'] = $auth; + $this->auth_infos['request_count'] = 1; + } + /* initial 401 or repeated request */ + if ($this->v('auth', 0, $this->auth_infos)) { + $qop = 'auth'; + $auth = $this->auth_infos['auth']; + $rc = $this->auth_infos['request_count']; + $realm = $this->auth_infos['realm']; + $nonce = $this->auth_infos['nonce']; + $ha1 = md5($creds['user'] . ':' . $realm . ':' . $creds['pass']); + $ha2 = md5($this->http_method . ':' . $path); + $nc = dechex($rc); + $cnonce = dechex($rc * 2); + $resp = md5($ha1 . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . $qop . ':' . $ha2); + $auth .= ', username="' . $creds['user'] . '"' . + ', uri="' . $path . '"' . + ', qop=' . $qop . '' . + ', nc=' . $nc . + ', cnonce="' . $cnonce . '"' . + ', uri="' . $path . '"' . + ', response="' . $resp . '"' . + ''; + $this->auth_infos['request_count'] = $rc + 1; + } + if (!$auth) return 0; + $h = in_array('proxy', $creds) ? 'Proxy-Authorization' : 'Authorization'; + $this->addCustomHeaders($h . ': ' . $auth); + } + + /* */ + + function useProxy($url) { + if (!$this->v1('proxy_host', 0, $this->a)) { + return false; + } + $skips = $this->v1('proxy_skip', array(), $this->a); + foreach ($skips as $skip) { + if (strpos($url, $skip) !== false) { + return false; + } + } + return true; + } + + /* */ + + function createStream($path, $data = '') { + $this->base = $this->calcBase($path); + $this->stream = ($data) ? $this->getDataStream($data) : $this->getSocketStream($this->base); + } + + function getDataStream($data) { + return array('type' => 'data', 'pos' => 0, 'headers' => array(), 'size' => strlen($data), 'data' => $data, 'buffer' => ''); + } + + function getSocketStream($url) { + if ($url == 'file://') { + return $this->addError('Error: file does not exists or is not accessible'); + } + $parts = parse_url($url); + $mappings = array('file' => 'File', 'http' => 'HTTP', 'https' => 'HTTP'); + if ($scheme = $this->v(strtolower($parts['scheme']), '', $mappings)) { + return $this->m('get' . $scheme . 'Socket', $url, $this->getDataStream('')); + } + } + + function getFileSocket($url) { + $parts = parse_url($url); + $s = file_exists($parts['path']) ? @fopen($parts['path'], 'rb') : false; + if (!$s) { + return $this->addError('Socket error: Could not open "' . $parts['path'] . '"'); + } + return array('type' => 'socket', 'socket' =>& $s, 'headers' => array(), 'pos' => 0, 'size' => filesize($parts['path']), 'buffer' => ''); + } + + function getHTTPSocket($url, $redirs = 0, $prev_parts = '') { + $parts = parse_url($url); + /* relative redirect */ + if (!isset($parts['scheme']) && $prev_parts) $parts['scheme'] = $prev_parts['scheme']; + if (!isset($parts['host']) && $prev_parts) $parts['host'] = $prev_parts['host']; + /* no scheme */ + if (!$this->v('scheme', '', $parts)) return $this->addError('Socket error: Missing URI scheme.'); + /* port tweaks */ + $parts['port'] = ($parts['scheme'] == 'https') ? $this->v1('port', 443, $parts) : $this->v1('port', 80, $parts); + $nl = "\r\n"; + $http_mthd = strtoupper($this->http_method); + if ($this->v1('user', 0, $parts) || $this->useProxy($url)) { + $h_code = $http_mthd . ' ' . $url; + } + else { + $h_code = $http_mthd . ' ' . $this->v1('path', '/', $parts) . (($v = $this->v1('query', 0, $parts)) ? '?' . $v : '') . (($v = $this->v1('fragment', 0, $parts)) ? '#' . $v : ''); + } + $scheme_default_port = ($parts['scheme'] == 'https') ? 443 : 80; + $port_code = ($parts['port'] != $scheme_default_port) ? ':' . $parts['port'] : ''; + $h_code .= ' HTTP/1.0' . $nl. + 'Host: ' . $parts['host'] . $port_code . $nl . + (($v = $this->http_accept_header) ? $v . $nl : '') . + (($v = $this->http_user_agent_header) && !preg_match('/User\-Agent\:/', $this->http_custom_headers) ? $v . $nl : '') . + (($http_mthd == 'POST') ? 'Content-Length: ' . strlen($this->message_body) . $nl : '') . + ($this->http_custom_headers ? trim($this->http_custom_headers) . $nl : '') . + $nl . + ''; + /* post body */ + if ($http_mthd == 'POST') { + $h_code .= $this->message_body . $nl; + } + /* connect */ + if ($this->useProxy($url)) { + $s = @fsockopen($this->a['proxy_host'], $this->a['proxy_port'], $errno, $errstr, $this->timeout); + } + elseif (($parts['scheme'] == 'https') && function_exists('stream_socket_client')) { + // SSL options via config array, code by Hannes Muehleisen (muehleis@informatik.hu-berlin.de) + $context = stream_context_create(); + foreach ($this->a as $k => $v) { + if (preg_match('/^arc_reader_ssl_(.+)$/', $k, $m)) { + stream_context_set_option($context, 'ssl', $m[1], $v); + } + } + $s = stream_socket_client('ssl://' . $parts['host'] . ":" . $parts['port'], $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $context); + } + elseif ($parts['scheme'] == 'https') { + $s = @fsockopen('ssl://' . $parts['host'], $parts['port'], $errno, $errstr, $this->timeout); + } + elseif ($parts['scheme'] == 'http') { + $s = @fsockopen($parts['host'], $parts['port'], $errno, $errstr, $this->timeout); + } + if (!$s) { + return $this->addError('Socket error: Could not connect to "' . $url . '" (proxy: ' . ($this->useProxy($url) ? '1' : '0') . '): ' . $errstr); + } + /* request */ + fwrite($s, $h_code); + /* timeout */ + if ($this->timeout) { + //stream_set_blocking($s, false); + stream_set_timeout($s, $this->timeout); + } + /* response headers */ + $h = array(); + $this->response_headers = $h; + if (!$this->ping_only) { + do { + $line = trim(fgets($s, 4096)); + $info = stream_get_meta_data($s); + if (preg_match("/^HTTP[^\s]+\s+([0-9]{1})([0-9]{2})(.*)$/i", $line, $m)) {/* response code */ + $error = in_array($m[1], array('4', '5')) ? $m[1] . $m[2] . ' ' . $m[3] : ''; + $error = ($m[1].$m[2] == '304') ? '304 '.$m[3] : $error; + $h['response-code'] = $m[1] . $m[2]; + $h['error'] = $error; + $h['redirect'] = ($m[1] == '3') ? true : false; + } + elseif (preg_match('/^([^\:]+)\:\s*(.*)$/', $line, $m)) {/* header */ + $h_name = strtolower($m[1]); + if (!isset($h[$h_name])) {/* 1st value */ + $h[$h_name] = trim($m[2]); + } + elseif (!is_array($h[$h_name])) {/* 2nd value */ + $h[$h_name] = array($h[$h_name], trim($m[2])); + } + else {/* more values */ + $h[$h_name][] = trim($m[2]); + } + } + } while(!$info['timed_out'] && !feof($s) && $line); + $h['format'] = strtolower(preg_replace('/^([^\s]+).*$/', '\\1', $this->v('content-type', '', $h))); + $h['encoding'] = preg_match('/(utf\-8|iso\-8859\-1|us\-ascii)/', $this->v('content-type', '', $h), $m) ? strtoupper($m[1]) : ''; + $h['encoding'] = preg_match('/charset=\s*([^\s]+)/si', $this->v('content-type', '', $h), $m) ? strtoupper($m[1]) : $h['encoding']; + $this->response_headers = $h; + /* result */ + if ($info['timed_out']) { + return $this->addError('Connection timed out after ' . $this->timeout . ' seconds'); + } + /* error */ + if ($v = $this->v('error', 0, $h)) { + /* digest auth */ + /* 401 received */ + if (preg_match('/Digest/i', $this->v('www-authenticate', '', $h)) && !$this->digest_auth) { + $this->setCredentials($url); + $this->digest_auth = 1; + return $this->getHTTPSocket($url); + } + return $this->addError($error . ' "' . (!feof($s) ? trim(strip_tags(fread($s, 128))) . '..."' : '')); + } + /* redirect */ + if ($this->v('redirect', 0, $h) && ($new_url = $this->v1('location', 0, $h))) { + fclose($s); + $this->redirects[$url] = $new_url; + $this->base = $new_url; + if ($redirs > $this->max_redirects) { + return $this->addError('Max numbers of redirects exceeded.'); + } + return $this->getHTTPSocket($new_url, $redirs+1, $parts); + } + } + if ($this->timeout) { + stream_set_blocking($s, true); + } + return array('type' => 'socket', 'url' => $url, 'socket' =>& $s, 'headers' => $h, 'pos' => 0, 'size' => $this->v('content-length', 0, $h), 'buffer' => ''); + } + + function readStream($buffer_xml = true, $d_size = 1024) { + //if (!$s = $this->v('stream')) return ''; + if (!$s = $this->v('stream')) return $this->addError('missing stream in "readStream" ' . $this->uri); + $s_type = $this->v('type', '', $s); + $r = $s['buffer']; + $s['buffer'] = ''; + if ($s['size']) $d_size = min($d_size, $s['size'] - $s['pos']); + /* data */ + if ($s_type == 'data') { + $d = ($d_size > 0) ? substr($s['data'], $s['pos'], $d_size) : ''; + } + /* socket */ + elseif ($s_type == 'socket') { + $d = ($d_size > 0) && !feof($s['socket']) ? fread($s['socket'], $d_size) : ''; + } + $eof = $d ? false : true; + /* chunked despite HTTP 1.0 request */ + if (isset($s['headers']) && isset($s['headers']['transfer-encoding']) && ($s['headers']['transfer-encoding'] == 'chunked')) { + $d = preg_replace('/(^|[\r\n]+)[0-9a-f]{1,4}[\r\n]+/', '', $d); + } + $s['pos'] += strlen($d); + if ($buffer_xml) {/* stop after last closing xml tag (if available) */ + if (preg_match('/^(.*\>)([^\>]*)$/s', $d, $m)) { + $d = $m[1]; + $s['buffer'] = $m[2]; + } + elseif (!$eof) { + $s['buffer'] = $r . $d; + $this->stream = $s; + return $this->readStream(true, $d_size); + } + } + $this->stream = $s; + return $r . $d; + } + + function closeStream() { + if (isset($this->stream)) { + if ($this->v('type', 0, $this->stream) == 'socket' && !empty($this->stream['socket'])) { + @fclose($this->stream['socket']); + } + unset($this->stream); + } + } + + /* */ + + function getFormat() { + if (!$this->format) { + if (!$this->v('stream')) { + return $this->addError('missing stream in "getFormat"'); + } + $v = $this->readStream(false); + $mtype = $this->v('format', '', $this->stream['headers']); + $this->stream['buffer'] = $v . $this->stream['buffer']; + $ext = preg_match('/\.([^\.]+)$/', $this->uri, $m) ? $m[1] : ''; + $this->format = ARC2::getFormat($v, $mtype, $ext); + } + return $this->format; + } + + /* */ + + function getResponseHeaders() { + if (isset($this->stream) && isset($this->stream['headers'])) { + return $this->stream['headers']; + } + return $this->response_headers; + } + + function getEncoding($default = 'UTF-8') { + return $this->v1('encoding', $default, $this->stream['headers']); + } + + function getRedirects() { + return $this->redirects; + } + + function getAuthInfos() { + return $this->auth_infos; + } + + /* */ + +} diff --git a/arc2-2.2.4/ARC2_Resource.php b/arc2-2.2.4/ARC2_Resource.php new file mode 100755 index 0000000..2bc4ca8 --- /dev/null +++ b/arc2-2.2.4/ARC2_Resource.php @@ -0,0 +1,150 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 + * @version 2011-01-19 +*/ + +ARC2::inc('Class'); + +class ARC2_Resource extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->uri = ''; + $this->index = array(); + $this->fetched = array(); + $this->store = ''; + } + + /* */ + + function setURI($uri) { + $this->uri = $uri; + } + + function setIndex($index) { + $this->index = $index; + } + + function getIndex() { + return $this->index; + } + + function setProps($props, $s = '') { + if (!$s) $s = $this->uri; + $this->index[$s] = $props; + } + + function setProp($p, $os, $s = '') { + if (!$s) $s = $this->uri; + /* single plain value */ + if (!is_array($os)) $os = array('value' => $os, 'type' => 'literal'); + /* single array value */ + if (isset($os['value'])) $os = array($os); + /* list of values */ + foreach ($os as $i => $o) { + if (!is_array($o)) $os[$i] = array('value' => $o, 'type' => 'literal'); + } + $this->index[$s][$this->expandPName($p)] = $os; + } + + /* add a relation to a URI. Allows for instance $res->setRel('rdf:type', 'doap:Project') */ + function setRel($p, $r, $s = '') { + if(!is_array($r)) { + $uri = array ( + 'type' => 'uri', + 'value' => $this->expandPName($r)); + $this->setProp($p, $uri, $s); + } else { + if (!$s) $s = $this->uri; + foreach($r as $i => $x) { + if(!is_array($x)) { + $uri = array ( + 'type' => 'uri', + 'value' => $this->expandPName($x)); + $r[$i] = $uri; + } + } + $this->index[$s][$this->expandPName($p)] = $r; + } + } + + /* Specialize setProp to set an xsd:dateTime typed literal. Example : $res->setPropXSDdateTime('dcterms:created', date('c')) */ + function setPropXSDdateTime($p, $dt, $s = '') { + $datecreated=array('value' => $dt, + 'type' => 'literal', + 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'); + $this->setProp($p, $datecreated, $s); + } + + function setStore($store) { + $this->store = $store; + } + + /* */ + + function fetchData($uri = '') { + if (!$uri) $uri = $this->uri; + if (!$uri) return 0; + if (in_array($uri, $this->fetched)) return 0; + $this->index[$uri] = array(); + if ($this->store) { + $index = $this->store->query('CONSTRUCT { <' . $uri . '> ?p ?o . } WHERE { <' . $uri . '> ?p ?o . } ', 'raw'); + } + else { + $index = $this->toIndex($uri); + } + $this->index = ARC2::getMergedIndex($this->index, $index); + $this->fetched[] = $uri; + } + + /* */ + + function getProps($p = '', $s = '') { + if (!$s) $s = $this->uri; + if (!$s) return array(); + if (!isset($this->index[$s])) $this->fetchData($s); + if (!$p) return $this->index[$s]; + return $this->v($this->expandPName($p), array(), $this->index[$s]); + } + + function getProp($p, $s = '') { + $props = $this->getProps($p, $s); + return $props ? $props[0] : ''; + } + + function getPropValue($p, $s = '') { + $prop = $this->getProp($p, $s); + return $prop ? $prop['value'] : ''; + } + + function getPropValues($p, $s = '') { + $r = array(); + $props = $this->getProps($p, $s); + foreach ($props as $prop) { + $r[] = $prop['value']; + } + return $r; + } + + function hasPropValue($p, $o, $s = '') { + $props = $this->getProps($p, $s); + $o = $this->expandPName($o); + foreach ($props as $prop) { + if ($prop['value'] == $o) return 1; + } + return 0; + } + + /* */ + +} diff --git a/arc2-2.2.4/ARC2_getFormat.php b/arc2-2.2.4/ARC2_getFormat.php new file mode 100755 index 0000000..c7b20ed --- /dev/null +++ b/arc2-2.2.4/ARC2_getFormat.php @@ -0,0 +1,66 @@ + + * @license http://arc.semsol.org/license + * @package ARC2 + * @version 2010-11-16 +*/ + +function ARC2_getFormat($v, $mtype = '', $ext = '') { + $r = false; + /* mtype check (atom, rdf/xml, turtle, n3, mp3, jpg) */ + $r = (!$r && preg_match('/\/atom\+xml/', $mtype)) ? 'atom' : $r; + $r = (!$r && preg_match('/\/rdf\+xml/', $mtype)) ? 'rdfxml' : $r; + $r = (!$r && preg_match('/\/(x\-)?turtle/', $mtype)) ? 'turtle' : $r; + $r = (!$r && preg_match('/\/rdf\+n3/', $mtype)) ? 'n3' : $r; + $r = (!$r && preg_match('/\/sparql-results\+xml/', $mtype)) ? 'sparqlxml' : $r; + /* xml sniffing */ + if ( + !$r && + /* starts with angle brackets */ + preg_match('/^\s*\<[^\s]/s', $v) && + /* has an xmlns:* declaration or a matching pair of tags */ + (preg_match('/\sxmlns\:?/', $v) || preg_match('/\<([^\s]+).+\<\/\\1\>/s', $v)) // && + ) { + while (preg_match('/^\s*\<\?xml[^\r\n]+\?\>\s*/s', $v)) { + $v = preg_replace('/^\s*\<\?xml[^\r\n]+\?\>\s*/s', '', $v); + } + while (preg_match('/^\s*\<\!--.+?--\>\s*/s', $v)) { + $v = preg_replace('/^\s*\<\!--.+?--\>\s*/s', '', $v); + } + /* doctype checks (html, rdf) */ + $r = (!$r && preg_match('/^\s*\<\!DOCTYPE\s+html[\s|\>]/is', $v)) ? 'html' : $r; + $r = (!$r && preg_match('/^\s*\<\!DOCTYPE\s+[a-z0-9\_\-]\:RDF\s/is', $v)) ? 'rdfxml' : $r; + /* markup checks */ + $v = preg_replace('/^\s*\<\!DOCTYPE\s.*\]\>/is', '', $v); + $r = (!$r && preg_match('/^\s*\]*version/s', $v)) ? 'rss' : $r; + $r = (!$r && preg_match('/^\s*\]+http\:\/\/www\.w3\.org\/2005\/Atom/s', $v)) ? 'atom' : $r; + $r = (!$r && preg_match('/^\s*\]/is', $v)) ? 'html' : $r; + $r = (!$r && preg_match('/^\s*\]+http\:\/\/www\.w3\.org\/2005\/sparql\-results\#/s', $v)) ? 'sparqlxml' : $r; + $r = (!$r && preg_match('/^\s*\<[^\>]+http\:\/\/www\.w3\.org\/2005\/sparql\-results#/s', $v)) ? 'srx' : $r; + $r = (!$r && preg_match('/^\s*\<[^\s]*RDF[\s\>]/s', $v)) ? 'rdfxml' : $r; + $r = (!$r && preg_match('/^\s*\<[^\>]+http\:\/\/www\.w3\.org\/1999\/02\/22\-rdf/s', $v)) ? 'rdfxml' : $r; + + $r = !$r ? 'xml' : $r; + } + /* json|jsonp */ + if (!$r && preg_match('/^[a-z0-9\.\(]*\s*[\{\[].*/s', trim($v))) { + /* google social graph api */ + $r = (!$r && preg_match('/\"canonical_mapping\"/', $v)) ? 'sgajson' : $r; + /* crunchbase api */ + $r = (!$r && preg_match('/\"permalink\"/', $v)) ? 'cbjson' : $r; + + $r = !$r ? 'json' : $r; + } + /* turtle/n3 */ + $r = (!$r && preg_match('/\@(prefix|base)/i', $v)) ? 'turtle' : $r; + $r = (!$r && preg_match('/^(ttl)$/', $ext)) ? 'turtle' : $r; + $r = (!$r && preg_match('/^(n3)$/', $ext)) ? 'n3' : $r; + /* ntriples */ + $r = (!$r && preg_match('/^\s*(_:|<).+?\s+<[^>]+?>\s+\S.+?\s*\.\s*$/sm', $v)) ? 'ntriples' : $r; + $r = (!$r && preg_match('/^(nt)$/', $ext)) ? 'ntriples' : $r; + return $r; +} diff --git a/arc2-2.2.4/ARC2_getPreferredFormat.php b/arc2-2.2.4/ARC2_getPreferredFormat.php new file mode 100755 index 0000000..382d83d --- /dev/null +++ b/arc2-2.2.4/ARC2_getPreferredFormat.php @@ -0,0 +1,50 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +function ARC2_getPreferredFormat($default = 'plain') { + $formats = array( + 'html' => 'HTML', 'text/html' => 'HTML', 'xhtml+xml' => 'HTML', + 'rdfxml' => 'RDFXML', 'rdf+xml' => 'RDFXML', + 'ntriples' => 'NTriples', + 'rdf+n3' => 'Turtle', 'x-turtle' => 'Turtle', 'turtle' => 'Turtle', 'text/turtle' => 'Turtle', + 'rdfjson' => 'RDFJSON', 'json' => 'RDFJSON', + 'xml' => 'XML', + 'legacyjson' => 'LegacyJSON' + ); + $prefs = array(); + $o_vals = array(); + /* accept header */ + $vals = explode(',', $_SERVER['HTTP_ACCEPT']); + if ($vals) { + foreach ($vals as $val) { + if (preg_match('/(rdf\+n3|(x\-|text\/)turtle|rdf\+xml|text\/html|xhtml\+xml|xml|json)/', $val, $m)) { + $o_vals[$m[1]] = 1; + if (preg_match('/\;q\=([0-9\.]+)/', $val, $sub_m)) { + $o_vals[$m[1]] = 1 * $sub_m[1]; + } + } + } + } + /* arg */ + if (isset($_GET['format'])) $o_vals[$_GET['format']] = 1.1; + /* rank */ + arsort($o_vals); + foreach ($o_vals as $val => $prio) { + $prefs[] = $val; + } + /* default */ + $prefs[] = $default; + foreach ($prefs as $pref) { + if (isset($formats[$pref])) { + return $formats[$pref]; + } + } +} diff --git a/arc2-2.2.4/README.md b/arc2-2.2.4/README.md new file mode 100755 index 0000000..8f1d0b7 --- /dev/null +++ b/arc2-2.2.4/README.md @@ -0,0 +1,8 @@ +ARC2 +==== + +ARC2 is a PHP 5.3 library for working with RDF. +It also provides a MySQL-based triplestore with SPARQL support. + +Feature-wise, ARC2 is now in a stable state with no further feature additions planned. +Issues are still being fixed and Pull Requests are welcome, though. \ No newline at end of file diff --git a/arc2-2.2.4/build.xml b/arc2-2.2.4/build.xml new file mode 100755 index 0000000..a9806c9 --- /dev/null +++ b/arc2-2.2.4/build.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/arc2-2.2.4/composer.json b/arc2-2.2.4/composer.json new file mode 100755 index 0000000..9e52cd0 --- /dev/null +++ b/arc2-2.2.4/composer.json @@ -0,0 +1,21 @@ +{ + "name": "semsol/arc2", + "type": "library", + "description": "Semsol's ARC2 RDF library", + "keywords": ["rdf","sparql"], + "homepage": "https://github.com/semsol/arc2", + "license": "W3C", + "authors": [ + { + "name": "Benji Nowack", + "email": "mail@bnowack.de", + "homepage": "http://bnowack.de/" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "classmap": ["./","parsers/","serializers/"] + } +} diff --git a/arc2-2.2.4/extractors/ARC2_DcExtractor.php b/arc2-2.2.4/extractors/ARC2_DcExtractor.php new file mode 100755 index 0000000..778c335 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_DcExtractor.php @@ -0,0 +1,80 @@ +a['ns']['dc'] = 'http://purl.org/dc/elements/1.1/'; + } + + /* */ + + function extractRDF() { + $t_vals = array(); + $t = ''; + foreach ($this->nodes as $n) { + foreach (array('title', 'link', 'meta') as $tag) { + if ($n['tag'] == $tag) { + $m = 'extract' . ucfirst($tag); + list ($t_vals, $t) = $this->$m($n, $t_vals, $t); + } + } + } + if ($t) { + $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']); + $this->addTs(ARC2::getTriplesFromIndex($doc)); + } + } + + /* */ + + function extractTitle($n, $t_vals, $t) { + if ($t_vals['title'] = $this->getPlainContent($n)) { + $t .= '<' . $n['doc_url'] . '> dc:title ?title . '; + } + return array($t_vals, $t); + } + + /* */ + + function extractLink($n, $t_vals, $t) { + if ($this->hasRel($n, 'alternate') || $this->hasRel($n, 'meta')) { + if ($href = $this->v('href uri', '', $n['a'])) { + $t .= '<' . $n['doc_url'] . '> rdfs:seeAlso <' . $href . '> . '; + if ($v = $this->v('type', '', $n['a'])) { + $t .= '<' .$href. '> dc:format "' . $v . '" . '; + } + if ($v = $this->v('title', '', $n['a'])) { + $t .= '<' .$href. '> dc:title "' . $v . '" . '; + } + } + } + return array($t_vals, $t); + } + + function extractMeta($n, $t_vals, $t) { + if ($this->hasAttribute('http-equiv', $n, 'Content-Type') || $this->hasAttribute('http-equiv', $n, 'content-type')) { + if ($v = $this->v('content', '', $n['a'])) { + $t .= '<' . $n['doc_url'] . '> dc:format "' . $v . '" . '; + } + } + return array($t_vals, $t); + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_ErdfExtractor.php b/arc2-2.2.4/extractors/ARC2_ErdfExtractor.php new file mode 100755 index 0000000..4da20bc --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_ErdfExtractor.php @@ -0,0 +1,284 @@ +caller->detected_formats['erdf'])) return 0; + $root_node = $this->getRootNode(); + $base = $this->getDocBase(); + $ns = $this->getNamespaces(); + $context = array( + 'base' => $base, + 'prev_res' => $base, + 'cur_res' => $base, + 'ns' => $ns, + 'lang' => '', + ); + $this->processNode($root_node, $context); + } + + /* */ + + function getRootNode() { + foreach ($this->nodes as $id => $node) { + if ($node['tag'] == 'html') { + return $node; + } + } + return $this->nodes[0]; + } + + function getNamespaces() { + $r = array( + 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#' + ); + foreach ($this->nodes as $id => $node) { + if (preg_match('/^(link|a)$/', $node['tag']) && isset($node['a']['rel']) && preg_match('/schema\.([^\s]+)/is', $node['a']['rel'], $m) && isset($node['a']['href uri'])) { + $r[$m[1]] = $node['a']['href uri']; + } + } + return $r; + } + + /* */ + + function processNode($n, $ct) { + /* context */ + //$ct['lang'] = $this->v('xml:lang', $ct['lang'], $n['a']); + $ct['lang'] = ''; + $ct['prop_uris'] = $this->getPropertyURIs($n, $ct); + $ct['prev_res'] = $ct['cur_res']; + $ct['cur_res'] = $this->getCurrentResourceURI($n, $ct); + $ct['cur_obj_id'] = $this->getCurrentObjectID($n, $ct); + $ct['cur_obj_literal'] = $this->getCurrentObjectLiteral($n, $ct); + /* triple production (http://research.talis.com/2005/erdf/wiki/Main/SummaryOfTripleProductionRules) */ + foreach ($ct['prop_uris'] as $type => $uris) { + foreach ($uris as $uri) { + $rdf_type = preg_match('/^ /', $uri) ? 1 : 0; + /* meta + name */ + if (($type == 'name') && ($n['tag'] == 'meta')) { + $t = array( + 's' => $ct['cur_res'], + 's_type' => 'uri', + 'p' => $uri, + 'o' => $ct['cur_obj_literal']['value'], + 'o_type' => 'literal', + 'o_lang' => $ct['cur_obj_literal']['datatype'] ? '' : $ct['cur_obj_literal']['lang'], + 'o_datatype' => $ct['cur_obj_literal']['datatype'], + ); + $this->addT($t); + } + /* class */ + if ($type == 'class') { + if ($rdf_type) { + $s = $this->v('href uri', $ct['cur_res'], $n['a']); + $s = $this->v('src uri', $s, $n['a']); + $t = array( + 's' => $s, + 's_type' => 'uri', + 'p' => $ct['ns']['rdf'] . 'type', + 'o' => trim($uri), + 'o_type' => 'uri', + 'o_lang' => '', + 'o_datatype' => '', + ); + } + elseif (isset($n['a']['id'])) {/* used as object */ + $t = array( + 's' => $ct['prev_res'], + 's_type' => 'uri', + 'p' => $uri, + 'o' => $ct['cur_res'], + 'o_type' => 'uri', + 'o_lang' => '', + 'o_datatype' => '', + ); + } + else { + $t = array( + 's' => $ct['cur_res'], + 's_type' => 'uri', + 'p' => $uri, + 'o' => $ct['cur_obj_literal']['value'], + 'o_type' => 'literal', + 'o_lang' => $ct['cur_obj_literal']['datatype'] ? '' : $ct['cur_obj_literal']['lang'], + 'o_datatype' => $ct['cur_obj_literal']['datatype'], + ); + if (($o = $this->v('src uri', '', $n['a'])) || ($o = $this->v('href uri', '', $n['a']))) { + if (!$ct['prop_uris']['rel'] && !$ct['prop_uris']['rev']) { + $t['o'] = $o; + $t['o_type'] = 'uri'; + $t['o_lang'] = ''; + $t['o_datatype'] = ''; + } + } + } + $this->addT($t); + } + /* rel */ + if ($type == 'rel') { + if (($o = $this->v('src uri', '', $n['a'])) || ($o = $this->v('href uri', '', $n['a']))) { + $t = array( + 's' => $ct['cur_res'], + 's_type' => 'uri', + 'p' => $uri, + 'o' => $o, + 'o_type' => 'uri', + 'o_lang' => '', + 'o_datatype' => '', + ); + $this->addT($t); + } + } + /* rev */ + if ($type == 'rev') { + if (($s = $this->v('src uri', '', $n['a'])) || ($s = $this->v('href uri', '', $n['a']))) { + $t = array( + 's' => $s, + 's_type' => 'uri', + 'p' => $uri, + 'o' => $ct['cur_res'], + 'o_type' => 'uri', + 'o_lang' => '', + 'o_datatype' => '', + ); + $this->addT($t); + } + } + } + } + /* imgs */ + if ($n['tag'] == 'img') { + if (($s = $this->v('src uri', '', $n['a'])) && $ct['cur_obj_literal']['value']) { + $t = array( + 's' => $s, + 's_type' => 'uri', + 'p' => $ct['ns']['rdfs'] . 'label', + 'o' => $ct['cur_obj_literal']['value'], + 'o_type' => 'literal', + 'o_lang' => $ct['cur_obj_literal']['datatype'] ? '' : $ct['cur_obj_literal']['lang'], + 'o_datatype' => $ct['cur_obj_literal']['datatype'], + ); + $this->addT($t); + } + } + /* anchors */ + if ($n['tag'] == 'a') { + if (($s = $this->v('href uri', '', $n['a'])) && $ct['cur_obj_literal']['value']) { + $t = array( + 's' => $s, + 's_type' => 'uri', + 'p' => $ct['ns']['rdfs'] . 'label', + 'o' => $ct['cur_obj_literal']['value'], + 'o_type' => 'literal', + 'o_lang' => $ct['cur_obj_literal']['datatype'] ? '' : $ct['cur_obj_literal']['lang'], + 'o_datatype' => $ct['cur_obj_literal']['datatype'], + ); + $this->addT($t); + } + } + /* recurse */ + if ($n['tag'] == 'a') { + $ct['cur_res'] = $ct['cur_obj_id']; + } + $sub_nodes = $this->getSubNodes($n); + foreach ($sub_nodes as $sub_node) { + $this->processNode($sub_node, $ct); + } + } + + /* */ + + function getPropertyURIs($n, $ct) { + $r = array(); + foreach (array('rel', 'rev', 'class', 'name', 'src') as $type) { + $r[$type] = array(); + $vals = $this->v($type . ' m', array(), $n['a']); + foreach ($vals as $val) { + if (!trim($val)) continue; + list($uri, $sub_v) = $this->xQname(trim($val, '- '), $ct['base'], $ct['ns'], $type); + if (!$uri) continue; + $rdf_type = preg_match('/^-/', trim($val)) ? 1 : 0; + $r[$type][] = $rdf_type ? ' ' . $uri : $uri; + } + } + return $r; + } + + function getCurrentResourceURI($n, $ct) { + if (isset($n['a']['id'])) { + list($r, $sub_v) = $this->xURI('#' . $n['a']['id'], $ct['base'], $ct['ns']); + return $r; + } + return $ct['cur_res']; + } + + function getCurrentObjectID($n, $ct) { + foreach (array('href', 'src') as $a) { + if (isset($n['a'][$a])) { + list($r, $sub_v) = $this->xURI($n['a'][$a], $ct['base'], $ct['ns']); + return $r; + } + } + return $this->createBnodeID(); + } + + function getCurrentObjectLiteral($n, $ct) { + $r = array('value' => '', 'lang' => $ct['lang'], 'datatype' => ''); + if (isset($n['a']['content'])) { + $r['value'] = $n['a']['content']; + } + elseif (isset($n['a']['title'])) { + $r['value'] = $n['a']['title']; + } + else { + $r['value'] = $this->getPlainContent($n); + } + return $r; + } + + /* */ + + function xURI($v, $base, $ns, $attr_type = '') { + if ((list($sub_r, $sub_v) = $this->xQname($v, $base, $ns)) && $sub_r) { + return array($sub_r, $sub_v); + } + if (preg_match('/^(rel|rev|class|name)$/', $attr_type) && preg_match('/^[a-z0-9]+$/', $v)) { + return array(0, $v); + } + return array($this->calcURI($v, $base), ''); + } + + function xQname($v, $base, $ns) { + if ($sub_r = $this->x('([a-z0-9\-\_]+)[\-\.]([a-z0-9\-\_]+)', $v)) { + if (isset($ns[$sub_r[1]])) { + return array($ns[$sub_r[1]] . $sub_r[2], ''); + } + } + return array(0, $v); + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_MicroformatsExtractor.php b/arc2-2.2.4/extractors/ARC2_MicroformatsExtractor.php new file mode 100755 index 0000000..67ebb68 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_MicroformatsExtractor.php @@ -0,0 +1,178 @@ +terms = $this->getTerms(); + $this->ns_prefix = 'mf'; + $this->a['ns']['mf'] = 'http://poshrdf.org/ns/mf#'; + $this->caller->detected_formats['posh-rdf'] = 1; + } + + /* */ + + function preProcessNode($n) { + if (!$n) return $n; + /* remove existing poshRDF hooks */ + if (!is_array($n['a'])) $n['a'] = array(); + $n['a']['class'] = isset($n['a']['class']) ? preg_replace('/\s?rdf\-(s|p|o|o-xml)/', '', $n['a']['class']): ''; + if (!isset($n['a']['rel'])) $n['a']['rel'] = ''; + /* inject poshRDF hooks */ + foreach ($this->terms as $term => $infos) { + if ((!in_array('rel', $infos) && $this->hasClass($n, $term)) || $this->hasRel($n, $term)) { + if ($this->v('scope', '', $infos)) $infos[] = 'p'; + foreach (array('s', 'p', 'o', 'o-xml') as $type) { + if (in_array($type, $infos)) { + $n['a']['class'] .= ' rdf-' . $type; + $n['a']['class'] = preg_replace('/(^|\s)' . $term . '(\s|$)/s', '\\1mf-' . $term . '\\2', $n['a']['class']); + $n['a']['rel'] = preg_replace('/(^|\s)' . $term . '(\s|$)/s', '\\1mf-' . $term . '\\2', $n['a']['rel']); + } + } + } + } + $n['a']['class m'] = preg_split('/ /', $n['a']['class']); + $n['a']['rel m'] = preg_split('/ /', $n['a']['rel']); + return $n; + } + + function getPredicates($n, $ns) { + $ns = array('mf' => $ns['mf']); + return parent::getPredicates($n, $ns); + } + + function tweakObject($o, $p, $ct) { + $ns = $ct['ns']['mf']; + /* rel-tag, skill => extract from URL */ + if (in_array($p, array($ns . 'tag', $ns . 'skill'))) { + $o = preg_replace('/^.*\/([^\/]+)/', '\\1', trim($o, '/')); + $o = urldecode(rawurldecode($o)); + } + return $o; + } + + /* */ + + function getTerms() { + /* no need to define 'p' if scope is not empty */ + return array( + 'acquaintance' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'additional-name' => array('o', 'scope' => array('n')), + 'adr' => array('s', 'o', 'scope' => array('_doc', 'vcard')), + 'affiliation' => array('s', 'o', 'scope' => array('hresume')), + 'author' => array('s', 'o', 'scope' => array('hentry')), + 'bday' => array('o', 'scope' => array('vcard')), + 'bio' => array('o', 'scope' => array('vcard')), + 'best' => array('o', 'scope' => array('hreview')), + 'bookmark' => array('o', 'scope' => array('_doc', 'hentry', 'hreview')), + 'class' => array('o', 'scope' => array('vcard', 'vevent')), + 'category' => array('o', 's', 'scope' => array('vcard', 'vevent')), + 'child' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'co-resident' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'co-worker' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'colleague' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'contact' => array('o', 'scope' => array('_doc', 'hresume', 'hentry')), + 'country-name' => array('o', 'scope' => array('adr')), + 'crush' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'date' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'description' => array('o', 'scope' => array('vevent', 'hreview', 'xfolkentry')), + 'directory' => array('o', 'rel', 'scope' => array('_doc', 'hfeed', 'hentry', 'hreview')), + 'dtend' => array('o', 'scope' => array('vevent')), + 'dtreviewed' => array('o', 'scope' => array('hreview')), + 'dtstamp' => array('o', 'scope' => array('vevent')), + 'dtstart' => array('o', 'scope' => array('vevent')), + 'duration' => array('o', 'scope' => array('vevent')), + 'education' => array('s', 'o', 'scope' => array('hresume')), + 'email' => array('s', 'o', 'scope' => array('vcard')), + 'entry-title' => array('o', 'scope' => array('hentry')), + 'entry-content' => array('o-xml', 'scope' => array('hentry')), + 'entry-summary' => array('o', 'scope' => array('hentry')), + 'experience' => array('s', 'o', 'scope' => array('hresume')), + 'extended-address' => array('o', 'scope' => array('adr')), + 'family-name' => array('o', 'scope' => array('n')), + 'fn' => array('o', 'plain', 'scope' => array('vcard', 'item')), + 'friend' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'geo' => array('s', 'scope' => array('_doc', 'vcard', 'vevent')), + 'given-name' => array('o', 'scope' => array('n')), + 'hentry' => array('s', 'o', 'scope' => array('_doc', 'hfeed')), + 'hfeed' => array('s', 'scope' => array('_doc')), + 'honorific-prefix' => array('o', 'scope' => array('n')), + 'honorific-suffix' => array('o', 'scope' => array('n')), + 'hresume' => array('s', 'scope' => array('_doc')), + 'hreview' => array('s', 'scope' => array('_doc')), + 'item' => array('s', 'scope' => array('hreview')), + 'key' => array('o', 'scope' => array('vcard')), + 'kin' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'label' => array('o', 'scope' => array('vcard')), + 'last-modified' => array('o', 'scope' => array('vevent')), + 'latitude' => array('o', 'scope' => array('geo')), + 'license' => array('o', 'rel', 'scope' => array('_doc', 'hfeed', 'hentry', 'hreview')), + 'locality' => array('o', 'scope' => array('adr')), + 'location' => array('o', 'scope' => array('vevent')), + 'logo' => array('o', 'scope' => array('vcard')), + 'longitude' => array('o', 'scope' => array('geo')), + 'mailer' => array('o', 'scope' => array('vcard')), + 'me' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'met' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'muse' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'n' => array('s', 'o', 'scope' => array('vcard')), + 'neighbor' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'nickname' => array('o', 'plain', 'scope' => array('vcard')), + 'nofollow' => array('o', 'rel', 'scope' => array('_doc')), + 'note' => array('o', 'scope' => array('vcard')), + 'org' => array('o', 'xplain', 'scope' => array('vcard')), + 'parent' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'permalink' => array('o', 'scope' => array('hreview')), + 'photo' => array('o', 'scope' => array('vcard', 'item')), + 'post-office-box' => array('o', 'scope' => array('adr')), + 'postal-code' => array('o', 'scope' => array('adr')), + 'publication' => array('s', 'o', 'scope' => array('hresume')), + 'published' => array('o', 'scope' => array('hentry')), + 'rating' => array('o', 'scope' => array('hreview')), + 'region' => array('o', 'scope' => array('adr')), + 'rev' => array('o', 'scope' => array('vcard')), + 'reviewer' => array('s', 'o', 'scope' => array('hreview')), + 'role' => array('o', 'plain', 'scope' => array('vcard')), + 'sibling' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'skill' => array('o', 'scope' => array('hresume')), + 'sort-string' => array('o', 'scope' => array('vcard')), + 'sound' => array('o', 'scope' => array('vcard')), + 'spouse' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'status' => array('o', 'plain', 'scope' => array('vevent')), + 'street-address' => array('o', 'scope' => array('adr')), + 'summary' => array('o', 'scope' => array('vevent', 'hreview', 'hresume')), + 'sweetheart' => array('o', 'rel', 'scope' => array('_doc', 'hentry')), + 'tag' => array('o', 'rel', 'scope' => array('_doc', 'category', 'hfeed', 'hentry', 'skill', 'hreview', 'xfolkentry')), + 'taggedlink' => array('o', 'scope' => array('xfolkentry')), + 'title' => array('o', 'scope' => array('vcard')), + 'type' => array('o', 'scope' => array('adr', 'email', 'hreview', 'tel')), + 'tz' => array('o', 'scope' => array('vcard')), + 'uid' => array('o', 'scope' => array('vcard', 'vevent')), + 'updated' => array('o', 'scope' => array('hentry')), + 'url' => array('o', 'scope' => array('vcard', 'vevent', 'item')), + 'value' => array('o', 'scope' => array('email', 'adr', 'tel')), + 'vcard' => array('s', 'scope' => array('author', 'reviewer', 'affiliation', 'contact')), + 'version' => array('o', 'scope' => array('hreview')), + 'vevent' => array('s', 'scope' => array('_doc')), + 'worst' => array('o', 'scope' => array('hreview')), + 'xfolkentry' => array('s', 'scope' => array('_doc')), + ); + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_OpenidExtractor.php b/arc2-2.2.4/extractors/ARC2_OpenidExtractor.php new file mode 100755 index 0000000..57e7088 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_OpenidExtractor.php @@ -0,0 +1,62 @@ +a['ns']['foaf'] = 'http://xmlns.com/foaf/0.1/'; + } + + /* */ + + function extractRDF() { + $t_vals = array(); + $t = ''; + foreach ($this->nodes as $n) { + if (isset($n['tag']) && $n['tag'] == 'link') { + $m = 'extract' . ucfirst($n['tag']); + list ($t_vals, $t) = $this->$m($n, $t_vals, $t); + } + } + if ($t) { + $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']); + $this->addTs(ARC2::getTriplesFromIndex($doc)); + } + } + + /* */ + + function extractLink($n, $t_vals, $t) { + if ($this->hasRel($n, 'openid.server')) { + if ($href = $this->v('href uri', '', $n['a'])) { + $t_vals['doc_owner'] = $this->getDocOwnerID($n); + $t_vals['doc_id'] = $this->getDocID($n); + $t .= '?doc_owner foaf:homepage ?doc_id ; foaf:openid ?doc_id . '; + } + } + if ($this->hasRel($n, 'openid.delegate')) { + if ($href = $this->v('href uri', '', $n['a'])) { + $t_vals['doc_owner'] = $this->getDocOwnerID($n); + $t .= '?doc_owner foaf:homepage <' . $href . '> ; foaf:openid <' . $href . '> . '; + } + } + return array($t_vals, $t); + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_PoshRdfExtractor.php b/arc2-2.2.4/extractors/ARC2_PoshRdfExtractor.php new file mode 100755 index 0000000..40d8368 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_PoshRdfExtractor.php @@ -0,0 +1,254 @@ +terms = $this->v('posh_terms', array(), $this->a); + $this->ns_prefix = 'posh'; + $this->a['ns'] += array( + 'an' => 'http://www.w3.org/2000/10/annotation-ns#', + 'content' => 'http://purl.org/rss/1.0/modules/content/', + 'dc' => 'http://purl.org/dc/elements/1.1/', + 'dct' => 'http://purl.org/dc/terms/', + 'foaf' => 'http://xmlns.com/foaf/0.1/', + 'geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#', + 'ical' => 'http://www.w3.org/2002/12/cal/icaltzd#', + 'owl' => 'http://www.w3.org/2002/07/owl#', + 'posh' => 'http://poshrdf.org/ns/posh/', + 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', + 'rev' => 'http://www.purl.org/stuff/rev#', + 'rss' => 'http://purl.org/rss/1.0/', + 'sioc' => 'http://rdfs.org/sioc/ns#', + 'skos' => 'http://www.w3.org/2008/05/skos#', + 'uri' => 'http://www.w3.org/2006/uri#', + 'vcard' => 'http://www.w3.org/2006/vcard/ns#', + 'xfn' => 'http://gmpg.org/xfn/11#', + 'xml' => 'http://www.w3.org/XML/1998/namespace', + 'xsd' => 'http://www.w3.org/2001/XMLSchema#', + ); + } + + /* */ + + function extractRDF() { + if (!isset($this->caller->detected_formats['posh-rdf'])) return 0; + $n = $this->getRootNode(); + $base = $this->getDocBase(); + $context = array( + 'id' => $n['id'], + 'tag' => $n['tag'], + 'base' => $base, + 's' => array(array('_doc', $base)), + 'next_s' => array('_doc', $base), + 'ps' => array(), + 'ns' => $this->a['ns'], + 'lang' => '', + 'rpointer' => '', + ); + $ct = $this->processNode($n, $context, 0, 1); + } + + /* */ + + function getRootNode() { + foreach ($this->nodes as $id => $node) { + if ($node['tag'] == 'html') { + return $node; + } + } + return $this->nodes[0]; + } + + /* */ + + function processNode($n, $ct, $level, $pos) { + $n = $this->preProcessNode($n); + /* local context */ + $lct = array_merge($ct, array( + 'ns' => array_merge($ct['ns'], $this->v('xmlns', array(), $n['a'])), + 'rpointer' => isset($n['a']['id']) ? $n['a']['id'] : ($n['tag'] == 'cdata' ? '' : $ct['rpointer'] . '/' . $pos), + 'tag' => $n['tag'], + 'id' => $n['id'], + 'lang' => $this->v('xml:lang', $ct['lang'], $n['a']), + )); + /* s stack */ + $next_s_key = $lct['next_s'][0]; + $next_s_val = $lct['next_s'][1]; + if ($lct['s'][0][0] != $next_s_key) { + $lct['s'] = array_merge(array($lct['next_s']), $lct['s']); + } + else { + $lct['s'][0][1] = $next_s_val; + } + /* new s */ + if ($this->hasClass($n, 'rdf-s')) { + $lct['next_s'] = array($n['a']['class'], $this->getSubject($n, $lct)); + //echo "\ns: " . print_r($lct['next_s'], 1); + } + /* p */ + if ($this->hasClass($n, 'rdf-p') || $this->hasRel($n, 'rdf-p')) { + if ($ps = $this->getPredicates($n, $lct['ns'])) { + $lct['ps'] = $ps; + $this->addPoshTypes($lct); + } + } + /* o */ + $cls = $this->v('class', '', $n['a']); + if ($lct['ps'] && preg_match('/(^|\s)rdf\-(o|o\-(xml|dateTime|float|integer|boolean))($|\s)/s', $cls, $m)) { + $this->addTriples($n, $lct, $m[3]); + } + /* sub-nodes */ + if ($sub_nodes = $this->getSubNodes($n)) { + $cur_ct = $lct; + $sub_pos = 1; + foreach ($sub_nodes as $i => $sub_node) { + if (in_array($sub_node['tag'], array('cdata', 'comment'))) continue; + $sub_ct = $this->processNode($sub_node, $cur_ct, $level + 1, $sub_pos); + $sub_pos++; + $cur_ct['next_s'] = $sub_ct['next_s']; + $cur_ct['ps'] = $sub_ct['ps']; + } + } + return $lct; + } + + /* */ + + function getSubject($n, $ct) { + foreach (array('href uri', 'src uri', 'title', 'value') as $k) { + if (isset($n['a'][$k])) return $n['a'][$k]; + } + /* rpointer */ + return $ct['base'] . '#resource(' . $ct['rpointer'] . ')'; + } + + function getPredicates($n, $ns) { + $r = array(); + /* try pnames */ + $vals = array_merge($this->v('class m', array(), $n['a']), $this->v('rel m', array(), $n['a'])); + foreach ($vals as $val) { + if (!preg_match('/^([a-z0-9]+)\-([a-z0-9\-\_]+)$/i', $val, $m)) continue; + if (!isset($ns[$m[1]])) continue; + if (preg_match('/^rdf-(s|p|o|o-(xml|dateTime|float|integer|boolean))$/', $val)) continue; + $r[] = $ns[$m[1]] . $m[2]; + } + /* try other attributes */ + if (!$r) { + foreach (array('href uri', 'title') as $k) { + if (isset($n['a'][$k])) { + $r[] = $n['a'][$k]; + break; + } + } + } + return $r; + } + + function addTriples($n, $ct, $o_type) { + foreach (array('href uri', 'src uri', 'title', 'value') as $k) { + if (isset($n['a'][$k])) { + $node_o = $n['a'][$k]; + break; + } + } + if (!isset($node_o) && $this->hasClass($n, 'rdf-s')) { + $node_o = $ct['next_s'][1]; + } + $lit_o = ($o_type == 'xml') ? $this->getContent($n) : $this->getPlainContent($n); + $posh_ns = $ct['ns'][$this->ns_prefix]; + $rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $xsd = 'http://www.w3.org/2001/XMLSchema#'; + foreach ($ct['ps'] as $p) { + $p_key = str_replace($posh_ns, '', $p); + /* dt or obj */ + $o = $this->isDatatypeProperty($p_key) ? $lit_o : (isset($node_o) ? $node_o : $lit_o); + if (!$o) continue; + if (!$s = $this->getContainerSubject($ct, $p_key)) continue; + $lang = (($o == $lit_o) && !$o_type) ? $ct['lang'] : ''; + $o = $this->tweakObject($o, $p, $ct); + $this->addT(array( + 's' => $this->getContainerSubject($ct, $p_key), + 's_type' => preg_match('/^\_\:/', $s) ? 'bnode' : 'uri', + 'p' => $p, + 'o' => $o, + 'o_type' => $this->getObjectType($o, $p_key), + 'o_lang' => $lang, + 'o_datatype' => ($o_type == 'xml') ? $rdf . 'XMLLiteral' : ($o_type ? $xsd . $o_type : ''), + )); + } + } + + function addPoshTypes($ct) { + $posh_ns = $ct['ns'][$this->ns_prefix]; + foreach ($ct['ps'] as $p) { + $p_key = str_replace($posh_ns, '', $p); + if (!$this->isSubject($p_key)) continue; + $s = $ct['next_s'][1]; + $this->addT(array( + 's' => $s, + 's_type' => preg_match('/^\_\:/', $s) ? 'bnode' : 'uri', + 'p' => $ct['ns']['rdf'] . 'type', + 'o' => $posh_ns . ucfirst($p_key), + 'o_type' => 'uri', + 'o_lang' => '', + 'o_datatype' => '', + )); + } + } + + /* */ + + function preProcessNode($n) { + return $n; + } + + function getContainerSubject($ct, $term) { + if (!isset($this->terms[$term])) return $ct['s'][0][1]; + $scope = $this->v('scope', array(), $this->terms[$term]); + if (!$scope) return $ct['s'][0][1]; + $scope_re = join('|', $scope); + foreach ($ct['s'] as $s) { + if (preg_match('/(^|\s)(' . $scope_re. ')($|\s)/s', str_replace($this->ns_prefix . '-', '', $s[0]))) return $s[1]; + } + return 0; + } + + function isSubject($term) { + if (!isset($this->terms[$term])) return 0; + return in_array('s', $this->terms[$term]); + } + + function isDatatypeProperty($term) { + if (!isset($this->terms[$term])) return 0; + return in_array('plain', $this->terms[$term]); + } + + function getObjectType($o, $term) { + if ($this->isDatatypeProperty($term)) return 'literal'; + if (strpos($o, ' ')) return 'literal'; + return preg_match('/^([a-z0-9\_]+)\:[^\s]+$/s', $o, $m) ? ($m[1] == '_' ? 'bnode' : 'uri') : 'literal'; + } + + function tweakObject($o, $p, $ct) { + return $o; + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_RDFExtractor.php b/arc2-2.2.4/extractors/ARC2_RDFExtractor.php new file mode 100755 index 0000000..df9ec23 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_RDFExtractor.php @@ -0,0 +1,237 @@ +nodes = $this->caller->getNodes(); + $this->index = $this->caller->getNodeIndex(); + $this->bnode_prefix = $this->v('bnode_prefix', 'arc' . substr(md5(uniqid(rand())), 0, 4) . 'b', $this->a); + $this->bnode_id = 0; + $this->keep_cdata_ws = $this->v('keep_cdata_whitespace', 0, $this->a); + if (!isset($this->a['ns'])) $this->a['ns'] = array('rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); + } + + /* */ + + function x($re, $v, $options = 'si') { + return ARC2::x($re, $v, $options); + } + + function createBnodeID(){ + $this->bnode_id++; + return '_:' . $this->bnode_prefix . $this->bnode_id; + } + + /* */ + + function extractRDF() { + } + + /* */ + + function addTs($ts) { + foreach ($ts as $t) { + $this->caller->addT($t); + } + } + + function addT($t) { + return $this->caller->addT($t); + } + + /* */ + + function getSubNodes($n) { + return $this->v($n['id'], array(), $this->index); + } + + function getParentNode($n) { + return isset($this->nodes[$n['p_id']]) ? $this->nodes[$n['p_id']] : 0; + } + + /* */ + + function getSubNodesByClass($n, $cls, $skip_self = 0) { + if (!$skip_self && $this->hasClass($n, $cls)) { + return array($n); + } + $r = array(); + $sns = $this->getSubNodes($n); + foreach ($sns as $sn) { + if ($sub_r = $this->getSubNodesByClass($sn, $cls, 0)) { + $r = array_merge($r, $sub_r); + } + } + return $r; + } + + function getSubNodeByClass($n, $cls, $skip_self = 0) { + if (!$skip_self && $this->hasClass($n, $cls)) { + return $n; + } + $sns = $this->getSubNodes($n); + foreach ($sns as $sn) { + if ($sub_r = $this->getSubNodeByClass($sn, $cls, 0)) { + return $sub_r; + } + } + return 0; + } + + function getParentNodeByClass($n, $cls, $skip_self = 0) { + if (!$skip_self && $this->hasClass($n, $cls)) { + return $n; + } + if ($pn = $this->getParentNode($n)) { + if ($sub_r = $this->getParentNodeByClass($pn, $cls, 0)) { + return $sub_r; + } + } + return 0; + } + + /* */ + + function hasAttribute($a, $n, $v) { + $vs = is_array($v) ? $v : array($v); + $a_vs = $this->v($a . ' m', array(), $n['a']); + return array_intersect($vs, $a_vs) ? 1 : 0; + } + + function hasClass($n, $v) { + return $this->hasAttribute('class', $n, $v); + } + + function hasRel($n, $v) { + return $this->hasAttribute('rel', $n, $v); + } + + /* */ + + function getDocBase() { + $root_node = $this->getRootNode(); + $r = $root_node['doc_base']; + foreach ($this->getSubNodes($root_node) as $root_child) { + if ($root_child['tag'] == 'head') { + foreach ($this->getSubNodes($root_child) as $head_child) { + if ($head_child['tag'] == 'base') { + $r = $head_child['a']['href']; + break; + } + } + } + } + return $r; + } + + /* */ + + function getPlainContent($n, $trim = 1, $use_img_alt = 1) { + if ($n['tag'] == 'comment') { + $r = ''; + } + elseif ($n['tag'] == 'cdata') { + $r = $n['a']['value']; + } + elseif (trim($this->v('cdata', '', $n))) { + $r = $n['cdata']; + $sub_nodes = $this->getSubNodes($n); + foreach ($sub_nodes as $sub_n) { + $r .= $this->getPlainContent($sub_n, 0, $use_img_alt); + } + } + elseif (($n['tag'] == 'img') && $use_img_alt && isset($n['a']['alt'])) { + $r = $n['a']['alt']; + } + else { + $r = ''; + $sub_nodes = $this->getSubNodes($n); + foreach ($sub_nodes as $sub_n) { + $r .= $this->getPlainContent($sub_n, 0, $use_img_alt); + } + } + $r = preg_replace('/\s/s', ' ', $r); + $r = preg_replace('/\s\s*/s', ' ', $r); + return $trim ? trim($r) : $r; + } + + function getContent($n, $outer = 0, $trim = 1) { + //echo '
' . htmlspecialchars(print_r($n, 1)) . '
'; + if ($n['tag'] == 'comment') { + $r = ''; + } + elseif ($n['tag'] == 'cdata') { + $r = $n['a']['value']; + } + else { + $r = ''; + if ($outer) { + $r .= '<' . $n['tag']; + asort($n['a']); + if (isset($n['a']['xmlns']) && $n['a']['xmlns']['']) { + $r .= ' xmlns="' . $n['a']['xmlns'][''] . '"'; + } + foreach ($n['a'] as $a => $val) { + if (!is_array($val) && isset($n['a'][$a . ' uri'])) $val = $n['a'][$a . ' uri']; + $r .= preg_match('/^[^\s]+$/', $a) && !is_array($val) ? ' ' . $a . '="' . addslashes($val) . '"' : ''; + } + $r .= $n['empty'] ? '/>' : '>'; + } + if (!$n['empty']) { + $r .= $this->v('cdata', '', $n); + $sub_nodes = $this->getSubNodes($n); + foreach ($sub_nodes as $sub_n) { + $r .= $this->getContent($sub_n, 1, 0); + } + if ($outer) { + $r .= ''; + } + } + } + return ($trim && !$this->keep_cdata_ws) ? trim($r) : $r; + } + + /* */ + + function getDocID($n) { + $id = $n['id']; + $k = 'doc_' . $id; + if (!isset($this->caller->cache[$k])) { + $this->caller->cache[$k] = $n['doc_url']; + } + return $this->caller->cache[$k]; + } + + function getDocOwnerID($n) { + return '_:owner_of_' . $this->normalize($this->getDocID($n)); + } + + /* */ + + function normalize($v) { + $v = preg_replace('/[\W\s]+/is', '_', strip_tags(strtolower($v))); + $v = preg_replace('/http/', '', $v); + $v = preg_replace('/[\_]+/', '_', $v); + //$v = substr($v, 0, 30); + $v = trim($v, '_'); + return $v; + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_RdfaExtractor.php b/arc2-2.2.4/extractors/ARC2_RdfaExtractor.php new file mode 100755 index 0000000..b0a00b0 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_RdfaExtractor.php @@ -0,0 +1,385 @@ +' . htmlspecialchars(print_r($this->nodes, 1)) . ''; + if (!isset($this->caller->detected_formats['rdfa'])) return 0; + $root_node = $this->getRootNode(); + //$base = $this->v('xml:base', $this->getDocBase(), $root_node['a']); + $base = $this->getDocBase(); + $context = array( + 'base' => $base, + 'p_s' => $base, + 'p_o' => '', + 'ns' => array(), + 'inco_ts' => array(), + 'lang' => '', + ); + $this->processNode($root_node, $context, 0); + } + + /* */ + + function getRootNode() { + foreach ($this->nodes as $id => $node) { + if ($node['tag'] == 'html') { + return $node; + } + } + return $this->nodes[0]; + } + + /* */ + + function processNode($n, $ct, $level) { + if ($n['tag']=='cdata' || $n['tag']=='comment') return null; /* patch by tobyink */ + $ts_added = 0; + /* step 1 */ + $lct = array(); + $lct['prev_s'] = $this->v('prev_s', $this->v('p_s', '', $ct), $ct); + $lct['recurse'] = 1; + $lct['skip'] = 0; + $lct['new_s'] = ''; + $lct['cur_o_res'] = ''; + $lct['inco_ts'] = array(); + $lct['base'] = $ct['base']; + //$lct['base'] = $this->v('xml:base', $ct['base'], $n['a']); + /* step 2 */ + $lct['ns'] = array_merge($ct['ns'], $this->v('xmlns', array(), $n['a'])); + /* step 3 */ + $lct['lang'] = $this->v('xml:lang', $ct['lang'], $n['a']); + /* step 4 */ + $rel_uris = $this->getAttributeURIs($n, $ct, $lct, 'rel'); + $rev_uris = $this->getAttributeURIs($n, $ct, $lct, 'rev'); + if (!$rel_uris && !$rev_uris) { + foreach (array('about', 'src', 'resource', 'href') as $attr) { + if (isset($n['a'][$attr]) && (list($uri, $sub_v) = $this->xURI($n['a'][$attr], $lct['base'], $lct['ns'], '', $lct)) && $uri) { + $lct['new_s'] = $uri; + break; + } + } + if (!$lct['new_s']) { + if (preg_match('/(head|body)/i', $n['tag'])) { + $lct['new_s'] = $lct['base']; + } + elseif ($this->getAttributeURIs($n, $ct, $lct, 'typeof')) { + $lct['new_s'] = $this->createBnodeID(); + } + elseif ($ct['p_o']) { + $lct['new_s'] = $ct['p_o']; + //$lct['skip'] = 1; + if(!isset($n['a']['property'])) $lct['skip'] = 1;/* patch by masaka */ + } + } + } + /* step 5 */ + else { + foreach (array('about', 'src') as $attr) { + if (isset($n['a'][$attr]) && (list($uri, $sub_v) = $this->xURI($n['a'][$attr], $lct['base'], $lct['ns'], '', $lct)) && $uri) { + $lct['new_s'] = $uri; + break; + } + } + if (!$lct['new_s']) { + if (preg_match('/(head|body)/i', $n['tag'])) { + $lct['new_s'] = $lct['base']; + } + elseif ($this->getAttributeURIs($n, $ct, $lct, 'typeof')) { + $lct['new_s'] = $this->createBnodeID(); + } + elseif ($ct['p_o']) { + $lct['new_s'] = $ct['p_o']; + } + } + foreach (array('resource', 'href') as $attr) { + if (isset($n['a'][$attr]) && (list($uri, $sub_v) = $this->xURI($n['a'][$attr], $lct['base'], $lct['ns'], '', $lct)) && $uri) { + $lct['cur_o_res'] = $uri; + break; + } + } + } + /* step 6 */ + if ($lct['new_s']) { + if ($uris = $this->getAttributeURIs($n, $ct, $lct, 'typeof')) { + foreach ($uris as $uri) { + $this->addT(array( + 's' => $lct['new_s'], + 's_type' => preg_match('/^\_\:/', $lct['new_s']) ? 'bnode' : 'uri', + 'p' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', + 'o' => $uri, + 'o_type' => 'uri', + 'o_lang' => '', + 'o_datatype' => '', + )); + $ts_added = 1; + } + } + /* step 7 */ + if ($lct['cur_o_res']) { + if ($rel_uris) { + foreach ($rel_uris as $uri) { + $this->addT(array( + 's' => $lct['new_s'], + 's_type' => preg_match('/^\_\:/', $lct['new_s']) ? 'bnode' : 'uri', + 'p' => $uri, + 'o' => $lct['cur_o_res'], + 'o_type' => preg_match('/^\_\:/', $lct['cur_o_res']) ? 'bnode' : 'uri', + 'o_lang' => '', + 'o_datatype' => '', + )); + $ts_added = 1; + } + } + if ($rev_uris) { + foreach ($rev_uris as $uri) { + $this->addT(array( + 's' => $lct['cur_o_res'], + 's_type' => preg_match('/^\_\:/', $lct['cur_o_res']) ? 'bnode' : 'uri', + 'p' => $uri, + 'o' => $lct['new_s'], + 'o_type' => preg_match('/^\_\:/', $lct['new_s']) ? 'bnode' : 'uri', + 'o_lang' => '', + 'o_datatype' => '', + )); + $ts_added = 1; + } + } + } + } + /* step 8 */ + if (!$lct['cur_o_res']) { + if ($rel_uris || $rev_uris) { + $lct['cur_o_res'] = $this->createBnodeID(); + foreach ($rel_uris as $uri) { + $lct['inco_ts'][] = array('p' => $uri, 'dir' => 'fwd'); + } + foreach ($rev_uris as $uri) { + $lct['inco_ts'][] = array('p' => $uri, 'dir' => 'rev'); + } + } + } + /* step 10 */ + if (!$lct['skip'] && ($new_s = $lct['new_s'])) { + //if ($new_s = $lct['new_s']) { + if ($uris = $this->getAttributeURIs($n, $ct, $lct, 'property')) { + foreach ($uris as $uri) { + $lct['cur_o_lit'] = $this->getCurrentObjectLiteral($n, $lct, $ct); + $this->addT(array( + 's' => $lct['new_s'], + 's_type' => preg_match('/^\_\:/', $lct['new_s']) ? 'bnode' : 'uri', + 'p' => $uri, + 'o' => $lct['cur_o_lit']['value'], + 'o_type' => 'literal', + 'o_lang' => $lct['cur_o_lit']['lang'], + 'o_datatype' => $lct['cur_o_lit']['datatype'], + )); + $ts_added = 1; + if ($lct['cur_o_lit']['datatype'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral') { + $lct['recurse'] = 0; + } + } + } + } + /* step 11 (10) */ + $complete_triples = 0; + if ($lct['recurse']) { + if ($lct['skip']) { + $new_ct = array_merge($ct, array('base' => $lct['base'], 'lang' => $lct['lang'], 'ns' => $lct['ns'])); + } + else { + $new_ct = array( + 'base' => $lct['base'], + 'p_s' => $lct['new_s'] ? $lct['new_s'] : $ct['p_s'], + 'p_o' => $lct['cur_o_res'] ? $lct['cur_o_res'] : ($lct['new_s'] ? $lct['new_s'] : $ct['p_s']), + 'ns' => $lct['ns'], + 'inco_ts' => $lct['inco_ts'], + 'lang' => $lct['lang'] + ); + } + $sub_nodes = $this->getSubNodes($n); + foreach ($sub_nodes as $sub_node) { + if ($this->processNode($sub_node, $new_ct, $level+1)) { + $complete_triples = 1; + } + } + } + /* step 12 (11) */ + $other = 0; + if ($ts_added || $complete_triples || ($lct['new_s'] && !preg_match('/^\_\:/', $lct['new_s'])) || ($other == 1)) { + //if (!$lct['skip'] && ($complete_triples || ($lct['new_s'] && !preg_match('/^\_\:/', $lct['new_s'])))) { + foreach ($ct['inco_ts'] as $inco_t) { + if ($inco_t['dir'] == 'fwd') { + $this->addT(array( + 's' => $ct['p_s'], + 's_type' => preg_match('/^\_\:/', $ct['p_s']) ? 'bnode' : 'uri', + 'p' => $inco_t['p'], + 'o' => $lct['new_s'], + 'o_type' => preg_match('/^\_\:/', $lct['new_s']) ? 'bnode' : 'uri', + 'o_lang' => '', + 'o_datatype' => '', + )); + } + elseif ($inco_t['dir'] == 'rev') { + $this->addT(array( + 's' => $lct['new_s'], + 's_type' => preg_match('/^\_\:/', $lct['new_s']) ? 'bnode' : 'uri', + 'p' => $inco_t['p'], + 'o' => $ct['p_s'], + 'o_type' => preg_match('/^\_\:/', $ct['p_s']) ? 'bnode' : 'uri', + 'o_lang' => '', + 'o_datatype' => '', + )); + } + } + } + /* step 13 (12) (result flag) */ + if ($ts_added) return 1; + if ($lct['new_s'] && !preg_match('/^\_\:/', $lct['new_s'])) return 1; + if ($complete_triples) return 1; + return 0; + } + + /* */ + + function getAttributeURIs($n, $ct, $lct, $attr) { + $vals = ($val = $this->v($attr, '', $n['a'])) ? explode(' ', $val) : array(); + $r = array(); + foreach ($vals as $val) { + if(!trim($val)) continue; + if ((list($uri, $sub_v) = $this->xURI(trim($val), $lct['base'], $lct['ns'], $attr, $lct)) && $uri) { + $r[] = $uri; + } + } + return $r; + } + + /* */ + + function getCurrentObjectLiteral($n, $lct, $ct) { + $xml_val = $this->getContent($n); + $plain_val = $this->getPlainContent($n, 0, 0); + if (function_exists('html_entity_decode')) { + $plain_val = html_entity_decode($plain_val, ENT_QUOTES); + } + $dt = $this->v('datatype', '', $n['a']); + list($dt_uri, $sub_v) = $this->xURI($dt, $lct['base'], $lct['ns'], '', $lct); + $dt = $dt ? $dt_uri : $dt; + $r = array('value' => '', 'lang' => $lct['lang'], 'datatype' => $dt); + if (isset($n['a']['content'])) { + $r['value'] = $n['a']['content']; + if (function_exists('html_entity_decode')) { + $r['value'] = html_entity_decode($r['value'], ENT_QUOTES); + } + } + elseif ($xml_val == $plain_val) { + $r['value'] = $plain_val; + } + elseif (!preg_match('/[\<\>]/', $xml_val)) { + $r['value'] = $xml_val; + } + elseif (isset($n['a']['datatype']) && ($dt != 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral')) { + $r['value'] = $plain_val; + } + elseif (!isset($n['a']['datatype']) || ($dt == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral')) { + $r['value'] = $this->injectXMLDeclarations($xml_val, $lct['ns'], $lct['lang']); + $r['datatype'] = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral'; + } + return $r; + } + + function injectXMLDeclarations($val, $ns, $lang) {//@@todo proper node rebuilding */ + $lang_code = $lang ? ' xml:lang="' . $lang . '"' : ''; + /* ns */ + $val = preg_replace('/<([a-z0-9]+)([\>\s])/is', '<\\1 xmlns="http://www.w3.org/1999/xhtml"' . $lang_code . '\\2', $val); + foreach ($ns as $prefix => $uri) { + if ($prefix && ($pos = strpos(' ' . $val, '<' . $prefix . ':'))) { + $val = substr($val, 0, $pos - 1) . preg_replace('/^(<' . $prefix . '\:[^\>\s]+)/', '\\1 xmlns:' . $prefix. '="' . $uri . '"' . $lang_code, substr($val, $pos - 1)); + } + } + /* remove accidentally added xml:lang and xmlns= */ + $val = preg_replace('/(\<[^\>]*)( xml\:lang[^\s\>]+)([^\>]*)(xml\:lang[^\s\>]+)/s', '\\1\\3\\4', $val); + $val = preg_replace('/(\<[^\>]*)( xmlns=[^\s\>]+)([^\>]*)(xmlns=[^\s\>]+)/s', '\\1\\3\\4', $val); + return $val; + } + + /* */ + + function xURI($v, $base, $ns, $attr_type = '', $lct = '') { + if ((list($sub_r, $sub_v) = $this->xBlankCURIE($v, $base, $ns)) && $sub_r) { + return array($sub_r, $sub_v); + } + if ((list($sub_r, $sub_v) = $this->xSafeCURIE($v, $base, $ns, $lct)) && $sub_r) { + return array($sub_r, $sub_v); + } + if ((list($sub_r, $sub_v) = $this->xCURIE($v, $base, $ns)) && $sub_r) { + return array($sub_r, $sub_v); + } + if (preg_match('/^(rel|rev)$/', $attr_type) && preg_match('/^\s*(alternate|appendix|bookmark|cite|chapter|contents|copyright|glossary|help|icon|index|last|license|meta|next|p3pv1|prev|role|section|stylesheet|subsection|start|up)(\s|$)/is', $v, $m)) { + return array('http://www.w3.org/1999/xhtml/vocab#' . strtolower($m[1]), preg_replace('/^\s*' . $m[1]. '/is', '', $v)); + } + if (preg_match('/^(rel|rev)$/', $attr_type) && preg_match('/^[a-z0-9\.]+$/i', $v)) { + return array(0, $v); + } + return array($this->calcURI($v, $base), ''); + } + + function xBlankCURIE($v, $base, $ns) { + if ($sub_r = $this->x('\[\_\:\]', $v)) { + $this->empty_bnode = isset($this->empty_bnode) ? $this->empty_bnode : $this->createBnodeID(); + return array($this->empty_bnode, ''); + } + if ($sub_r = $this->x('\[?(\_\:[a-z0-9\_\-]+)\]?', $v)) { + return array($sub_r[1], ''); + } + return array(0, $v); + } + + function xSafeCURIE($v, $base, $ns, $lct = '') { + /* empty */ + if ($sub_r = $this->x('\[\]', $v)) { + $r = $lct ? $lct['prev_s'] : $base;/* should be current subject value */ + return $sub_r[1] ? array($r, $sub_r[1]) : array($r, ''); + } + if ($sub_r = $this->x('\[([^\:]*)\:([^\]]*)\]', $v)) { + if (!$sub_r[1]) return array('http://www.w3.org/1999/xhtml/vocab#' . $sub_r[2], ''); + if (isset($ns[$sub_r[1]])) { + return array($ns[$sub_r[1]] . $sub_r[2], ''); + } + } + return array(0, $v); + } + + function xCURIE($v, $base, $ns) { + if ($sub_r = $this->x('([a-z0-9\-\_]*)\:([^\s]+)', $v)) { + if (!$sub_r[1]) return array('http://www.w3.org/1999/xhtml/vocab#' . $sub_r[2], ''); + if (isset($ns[$sub_r[1]])) { + return array($ns[$sub_r[1]] . $sub_r[2], ''); + } + } + return array(0, $v); + } + + /* */ + +} diff --git a/arc2-2.2.4/extractors/ARC2_TwitterProfilePicExtractor.php b/arc2-2.2.4/extractors/ARC2_TwitterProfilePicExtractor.php new file mode 100755 index 0000000..048cc63 --- /dev/null +++ b/arc2-2.2.4/extractors/ARC2_TwitterProfilePicExtractor.php @@ -0,0 +1,45 @@ +a['ns']['foaf'] = 'http://xmlns.com/foaf/0.1/'; + $this->a['ns']['mf'] = 'http://poshrdf.org/ns/mf#'; + } + + /* */ + + function extractRDF() { + $t_vals = array(); + $t = ''; + foreach ($this->nodes as $n) { + if (isset($n['tag']) && ($n['tag'] == 'img') && ($this->v('id', '', $n['a']) == 'profile-image')) { + $t_vals['vcard_id'] = $this->getDocID($n) . '#resource(side/1/2/1)'; + $t .= '?vcard_id mf:photo <' . $n['a']['src'] . '> . '; + break; + } + } + if ($t) { + $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']); + $this->addTs(ARC2::getTriplesFromIndex($doc)); + } + } + + /* */ + +} diff --git a/arc2-2.2.4/parsers/ARC2_AtomParser.php b/arc2-2.2.4/parsers/ARC2_AtomParser.php new file mode 100755 index 0000000..cabef40 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_AtomParser.php @@ -0,0 +1,245 @@ +triples = array(); + $this->target_encoding = ''; + $this->t_count = 0; + $this->added_triples = array(); + $this->skip_dupes = false; + $this->bnode_prefix = $this->v('bnode_prefix', 'arc'.substr(md5(uniqid(rand())), 0, 4).'b', $this->a); + $this->bnode_id = 0; + $this->cache = array(); + $this->allowCDataNodes = 0; + } + + /* */ + + function done() { + $this->extractRDF(); + } + + /* */ + + function setReader(&$reader) { + $this->reader = $reader; + } + + function createBnodeID(){ + $this->bnode_id++; + return '_:' . $this->bnode_prefix . $this->bnode_id; + } + + function addT($t) { + //if (!isset($t['o_datatype'])) + if ($this->skip_dupes) { + //$h = md5(print_r($t, 1)); + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + function getSimpleIndex($flatten_objects = 1, $vals = '') { + return ARC2::getSimpleIndex($this->getTriples(), $flatten_objects, $vals); + } + + /* */ + + function extractRDF() { + $index = $this->getNodeIndex(); + //print_r($index); + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->atom = 'http://www.w3.org/2005/Atom'; + $this->rss = 'http://purl.org/rss/1.0/'; + $this->dc = 'http://purl.org/dc/elements/1.1/'; + $this->sioc = 'http://rdfs.org/sioc/ns#'; + $this->dct = 'http://purl.org/dc/terms/'; + $this->content = 'http://purl.org/rss/1.0/modules/content/'; + $this->enc = 'http://purl.oclc.org/net/rss_2.0/enc#'; + $this->mappings = array( + 'feed' => $this->rss . 'channel', + 'entry' => $this->rss . 'item', + 'title' => $this->rss . 'title', + 'link' => $this->rss . 'link', + 'summary' => $this->rss . 'description', + 'content' => $this->content . 'encoded', + 'id' => $this->dc . 'identifier', + 'author' => $this->dc . 'creator', + 'category' => $this->dc . 'subject', + 'updated' => $this->dc . 'date', + 'source' => $this->dc . 'source', + ); + $this->dt_props = array( + $this->dc . 'identifier', + $this->rss . 'link' + ); + foreach ($index as $p_id => $nodes) { + foreach ($nodes as $pos => $node) { + $tag = $this->v('tag', '', $node); + if ($tag == 'feed') { + $struct = $this->extractChannel($index[$node['id']]); + $triples = ARC2::getTriplesFromIndex($struct); + foreach ($triples as $t) { + $this->addT($t); + } + } + elseif ($tag == 'entry') { + $struct = $this->extractItem($index[$node['id']]); + $triples = ARC2::getTriplesFromIndex($struct); + foreach ($triples as $t) { + $this->addT($t); + } + } + } + } + } + + function extractChannel($els) { + list($props, $sub_index) = $this->extractProps($els, 'channel'); + $uri = $props[$this->rss . 'link'][0]['value']; + return ARC2::getMergedIndex(array($uri => $props), $sub_index); + } + + function extractItem($els) { + list($props, $sub_index) = $this->extractProps($els, 'item'); + $uri = $props[$this->rss . 'link'][0]['value']; + return ARC2::getMergedIndex(array($uri => $props), $sub_index); + } + + function extractProps($els, $container) { + $r = array($this->rdf . 'type' => array(array('value' => $this->rss . $container, 'type' => 'uri'))); + $sub_index = array(); + foreach ($els as $info) { + /* key */ + $tag = $info['tag']; + if (!preg_match('/^[a-z0-9]+\:/i', $tag)) { + $k = isset($this->mappings[$tag]) ? $this->mappings[$tag] : ''; + } + elseif (isset($this->mappings[$tag])) { + $k = $this->mappings[$tag]; + } + else {/* qname */ + $k = $this->expandPName($tag); + } + //echo $k . "\n"; + if (($container == 'channel') && ($k == $this->rss . 'item')) continue; + /* val */ + $v = trim($info['cdata']); + if (!$v) $v = $this->v('href uri', '', $info['a']); + /* prop */ + if ($k) { + /* content handling */ + if (in_array($k, array($this->rss . 'description', $this->content . 'encoded'))) { + $v = $this->getNodeContent($info); + } + /* source handling */ + elseif ($k == $this->dc . 'source') { + $sub_nodes = $this->node_index[$info['id']]; + foreach ($sub_nodes as $sub_pos => $sub_info) { + if ($sub_info['tag'] == 'id') { + $v = trim($sub_info['cdata']); + } + } + } + /* link handling */ + elseif ($k == $this->rss . 'link') { + if ($link_type = $this->v('type', '', $info['a'])) { + $k2 = $this->dc . 'format'; + if (!isset($sub_index[$v])) $sub_index[$v] = array(); + if (!isset($sub_index[$v][$k2])) $sub_index[$v][$k2] = array(); + $sub_index[$v][$k2][] = array('value' => $link_type, 'type' => 'literal'); + } + } + /* author handling */ + elseif ($k == $this->dc . 'creator') { + $sub_nodes = $this->node_index[$info['id']]; + foreach ($sub_nodes as $sub_pos => $sub_info) { + if ($sub_info['tag'] == 'name') { + $v = trim($sub_info['cdata']); + } + if ($sub_info['tag'] == 'uri') { + $k2 = $this->sioc . 'has_creator'; + $v2 = trim($sub_info['cdata']); + if (!isset($r[$k2])) $r[$k2] = array(); + $r[$k2][] = array('value' => $v2, 'type' => 'uri'); + } + } + } + /* date handling */ + elseif (in_array($k, array($this->dc . 'date', $this->dct . 'modified'))) { + if (!preg_match('/^[0-9]{4}/', $v) && ($sub_v = strtotime($v)) && ($sub_v != -1)) { + $tz = date('Z', $sub_v); /* timezone offset */ + $sub_v -= $tz; /* utc */ + $v = date('Y-m-d\TH:i:s\Z', $sub_v); + } + } + /* tag handling */ + elseif ($k == $this->dc . 'subject') { + $v = $this->v('term', '', $info['a']); + } + /* other attributes in closed tags */ + elseif (!$v && ($info['state'] == 'closed') && $info['a']) { + foreach ($info['a'] as $sub_k => $sub_v) { + if (!preg_match('/(xmlns|\:|type)/', $sub_k)) { + $v = $sub_v; + break; + } + } + } + if (!isset($r[$k])) $r[$k] = array(); + $r[$k][] = array('value' => $v, 'type' => in_array($k, $this->dt_props) || !preg_match('/^[a-z0-9]+\:[^\s]+$/is', $v) ? 'literal' : 'uri'); + } + } + return array($r, $sub_index); + } + + function initXMLParser() { + if (!isset($this->xml_parser)) { + $enc = preg_match('/^(utf\-8|iso\-8859\-1|us\-ascii)$/i', $this->getEncoding(), $m) ? $m[1] : 'UTF-8'; + $parser = xml_parser_create($enc); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, 'open', 'close'); + xml_set_character_data_handler($parser, 'cData'); + xml_set_start_namespace_decl_handler($parser, 'nsDecl'); + xml_set_object($parser, $this); + $this->xml_parser = $parser; + } + } + + /* */ + + +} diff --git a/arc2-2.2.4/parsers/ARC2_CBJSONParser.php b/arc2-2.2.4/parsers/ARC2_CBJSONParser.php new file mode 100755 index 0000000..d59f77e --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_CBJSONParser.php @@ -0,0 +1,267 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('JSONParser'); + +class ARC2_CBJSONParser extends ARC2_JSONParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* reader */ + parent::__init(); + $this->base = 'http://cb.semsol.org/'; + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->default_ns = $this->base . 'ns#'; + $this->nsp = array($this->rdf => 'rdf'); + } + + /* */ + + function done() { + $this->extractRDF(); + } + + function extractRDF() { + $struct = $this->struct; + if ($type = $this->getStructType($struct)) { + $s = $this->getResourceID($struct, $type); + /* rdf:type */ + $this->addT($s, $this->rdf . 'type', $this->default_ns . $this->camelCase($type), 'uri', 'uri'); + /* explicit triples */ + $this->extractResourceRDF($struct, $s); + } + } + + function getStructType($struct, $rel = '') { + /* url-based */ + if ($url = $this->v('crunchbase_url', '', $struct)) { + return preg_replace('/^.*crunchbase\.com\/([^\/]+)\/.*$/', '\\1', $url); + } + /* rel-based */ + if ($rel == 'person') return 'person'; + if ($rel == 'company') return 'company'; + if ($rel == 'acquiring_company') return 'company'; + if ($rel == 'firm') return 'company'; + if ($rel == 'provider') return 'service-provider'; + /* struct-based */ + if (isset($struct['_type'])) return $struct['_type']; + if (isset($struct['round_code'])) return 'funding_round'; + if (isset($struct['products'])) return 'company'; + if (isset($struct['first_name'])) return 'person'; + if (isset($struct['investments'])) return 'financial-organization'; + if (isset($struct['launched_year'])) return 'product'; + if (isset($struct['providerships']) && is_array($struct['providerships'])) return 'service-provider'; + return ''; + } + + function getResourceID($struct, $type) { + if ($type && isset($struct['permalink'])) { + return $this->base . $type . '/' . $struct['permalink'] . '#self'; + } + return $this->createBnodeID(); + } + + function getPropertyURI($name, $ns = '') { + if (!$ns) $ns = $this->default_ns; + if (preg_match('/^(product|funding_round|investment|acquisition|.+ship|office|milestone|.+embed|.+link|degree|fund)s/', $name, $m)) $name = $m[1]; + if ($name == 'tag_list') $name = 'tag'; + if ($name == 'competitions') $name = 'competitor'; + return $ns . $name; + } + + function createSubURI($s, $k, $pos) { + $s = str_replace('#self', '/', $s); + if (preg_match('/(office|ship|investment|milestone|fund|embed|link)s$/', $k)) $k = substr($k, 0, -1); + return $s . $k . '-' . ($pos + 1) . '#self'; + } + + /* */ + + function extractResourceRDF($struct, $s, $pos = 0) { + $s_type = preg_match('/^\_\:/', $s) ? 'bnode' : 'uri'; + $date_prefixes = array(); + foreach ($struct as $k => $v) { + if ($k == 'acquisition') $k = 'exit'; + if (preg_match('/^(.*)\_(year|month|day)$/', $k, $m)) { + if (!in_array($m[1], $date_prefixes)) $date_prefixes[] = $m[1]; + } + $sub_m = 'extract' . $this->camelCase($k) . 'RDF'; + if (method_exists($this, $sub_m)) { + $this->$sub_m($s, $s_type, $v); + continue; + } + $p = $this->getPropertyURI($k); + if (!$v) continue; + /* simple, single v */ + if (!is_array($v)) { + $o_type = preg_match('/^[a-z]+\:[^\s]+$/is', $v) ? 'uri' : 'literal'; + $v = trim($v); + if (preg_match('/^https?\:\/\/[^\/]+$/', $v)) $v .= '/'; + $this->addT($s, $p, $v, $s_type, $o_type); + /* rdfs:label */ + if ($k == 'name') $this->addT($s, 'http://www.w3.org/2000/01/rdf-schema#label', $v, $s_type, $o_type); + /* dc:identifier */ + //if ($k == 'permalink') $this->addT($s, 'http://purl.org/dc/elements/1.1/identifier', $v, $s_type, $o_type); + } + /* structured, single v */ + elseif (!$this->isFlatArray($v)) { + if ($o_type = $this->getStructType($v, $k)) {/* known type */ + $o = $this->getResourceID($v, $o_type); + $this->addT($s, $p, $o, $s_type, 'uri'); + $this->addT($o, $this->rdf . 'type', $this->default_ns . $this->camelCase($o_type), 'uri', 'uri'); + } + else {/* unknown type */ + $o = $this->createSubURI($s, $k, $pos); + $this->addT($s, $p, $o, $s_type, 'uri'); + $this->extractResourceRDF($v, $o); + } + } + /* value list */ + else { + foreach ($v as $sub_pos => $sub_v) { + $this->extractResourceRDF(array($k => $sub_v), $s, $sub_pos); + } + } + } + /* infer XSD triples */ + foreach ($date_prefixes as $prefix) { + $this->inferDate($prefix, $s, $struct); + } + } + + function isFlatArray($v) { + foreach ($v as $k => $sub_v) { + return is_numeric($k) ? 1 : 0; + } + } + + /* */ + + function extractTagListRDF($s, $s_type, $v) { + if (!$v) return 0; + $tags = preg_split('/\, /', $v); + foreach ($tags as $tag) { + if (!trim($tag)) continue; + $this->addT($s, $this->getPropertyURI('tag'), $tag, $s_type, 'literal'); + } + } + + function extractImageRDF($s, $s_type, $v, $rel = 'image') { + if (!$v) return 1; + $sizes = $v['available_sizes']; + foreach ($sizes as $size) { + $w = $size[0][0]; + $h = $size[0][1]; + $img = 'http://www.crunchbase.com/' . $size[1]; + $this->addT($s, $this->getPropertyURI($rel), $img, $s_type, 'uri'); + $this->addT($img, $this->getPropertyURI('width'), $w, 'uri', 'literal'); + $this->addT($img, $this->getPropertyURI('height'), $h, 'uri', 'literal'); + } + } + + function extractScreenshotsRDF($s, $s_type, $v) { + if (!$v) return 1; + foreach ($v as $sub_v) { + $this->extractImageRDF($s, $s_type, $sub_v, 'screenshot'); + } + } + + function extractProductsRDF($s, $s_type, $v) { + foreach ($v as $sub_v) { + $o = $this->getResourceID($sub_v, 'product'); + $this->addT($s, $this->getPropertyURI('product'), $o, $s_type, 'uri'); + } + } + + function extractCompetitionsRDF($s, $s_type, $v) { + foreach ($v as $sub_v) { + $o = $this->getResourceID($sub_v['competitor'], 'company'); + $this->addT($s, $this->getPropertyURI('competitor'), $o, $s_type, 'uri'); + } + } + + function extractFundingRoundsRDF($s, $s_type, $v) { + foreach ($v as $pos => $sub_v) { + $o = $this->createSubURI($s, 'funding_round', $pos); + $this->addT($s, $this->getPropertyURI('funding_round'), $o, $s_type, 'uri'); + $this->extractResourceRDF($sub_v, $o, $pos); + } + } + + function extractInvestmentsRDF($s, $s_type, $v) { + foreach ($v as $pos => $sub_v) { + /* incoming */ + foreach (array('person' => 'person', 'company' => 'company', 'financial_org' => 'financial-organization') as $k => $type) { + if (isset($sub_v[$k])) $this->addT($s, $this->getPropertyURI('investment'), $this->getResourceID($sub_v[$k], $type), $s_type, 'uri'); + } + /* outgoing */ + if (isset($sub_v['funding_round'])) { + $o = $this->createSubURI($s, 'investment', $pos); + $this->addT($s, $this->getPropertyURI('investment'), $o, $s_type, 'uri'); + $this->extractResourceRDF($sub_v['funding_round'], $o, $pos); + } + } + } + + function extractExternalLinksRDF($s, $s_type, $v) { + foreach ($v as $sub_v) { + $href = $sub_v['external_url']; + if (preg_match('/^https?\:\/\/[^\/]+$/', $href)) $href .= '/'; + $this->addT($s, $this->getPropertyURI('external_link'), $href, $s_type, 'uri'); + $this->addT($href, $this->getPropertyURI('title'), $sub_v['title'], $s_type, 'literal'); + } + } + + function extractWebPresencesRDF($s, $s_type, $v) { + foreach ($v as $sub_v) { + $href = $sub_v['external_url']; + if (preg_match('/^https?\:\/\/[^\/]+$/', $href)) $href .= '/'; + $this->addT($s, $this->getPropertyURI('web_presence'), $href, $s_type, 'uri'); + $this->addT($href, $this->getPropertyURI('title'), $sub_v['title'], $s_type, 'literal'); + } + } + + function extractCreatedAtRDF($s, $s_type, $v) { + $v = $this->getAPIDateXSD($v); + $this->addT($s, $this->getPropertyURI('created_at'), $v, $s_type, 'literal'); + } + + function extractUpdatedAtRDF($s, $s_type, $v) { + $v = $this->getAPIDateXSD($v); + $this->addT($s, $this->getPropertyURI('updated_at'), $v, $s_type, 'literal'); + } + + function getAPIDateXSD($val) { + //Fri Jan 16 21:11:48 UTC 2009 + if (preg_match('/^[a-z]+ ([a-z]+) ([0-9]+) ([0-9]{2}\:[0-9]{2}\:[0-9]{2}) UTC ([0-9]{4})/i', $val, $m)) { + $months = array('Jan' => '01', 'Feb' => '02', 'Mar' =>'03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12'); + return $m[4] . '-' . $months[$m[1]] . '-' . $m[2] . 'T' . $m[3] . 'Z'; + } + return '2000-01-01'; + } + + /* */ + + function inferDate($prefix, $s, $struct) { + $s_type = preg_match('/^\_\:/', $s) ? 'bnode' : 'uri'; + $r = ''; + foreach (array('year', 'month', 'day') as $suffix) { + $val = $this->v1($prefix . '_' . $suffix, '00', $struct); + $r .= ($r ? '-' : '') . str_pad($val, 2, '0', STR_PAD_LEFT); + } + if ($r != '00-00-00') { + $this->addT($s, $this->getPropertyURI($prefix . '_date'), $r, $s_type, 'literal'); + } + } + +} diff --git a/arc2-2.2.4/parsers/ARC2_JSONParser.php b/arc2-2.2.4/parsers/ARC2_JSONParser.php new file mode 100755 index 0000000..f4d9b95 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_JSONParser.php @@ -0,0 +1,165 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFParser'); + +class ARC2_JSONParser extends ARC2_RDFParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + } + + /* */ + + function x($re, $v, $options = 'si') { + while (preg_match('/^\s*(\/\*.*\*\/)(.*)$/Usi', $v, $m)) {/* comment removal */ + $v = $m[2]; + } + $this->unparsed_code = (strlen($this->unparsed_code) > strlen($v)) ? $v : $this->unparsed_code; + return ARC2::x($re, $v, $options); + } + + function parse($path, $data = '') { + $this->state = 0; + /* reader */ + if (!$this->v('reader')) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->setAcceptHeader('Accept: application/json; q=0.9, */*; q=0.1'); + $this->reader->activate($path, $data); + $this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base; + /* parse */ + $doc = ''; + while ($d = $this->reader->readStream()) { + $doc .= $d; + } + $this->reader->closeStream(); + unset($this->reader); + $doc = preg_replace('/^[^\{]*(.*\})[^\}]*$/is', '\\1', $doc); + $this->unparsed_code = $doc; + list($this->struct, $rest) = $this->extractObject($doc); + return $this->done(); + } + + /* */ + + function extractObject($v) { + if (function_exists('json_decode')) return array(json_decode($v, 1), ''); + $r = array(); + /* sub-object */ + if ($sub_r = $this->x('\{', $v)) { + $v = $sub_r[1]; + while ((list($sub_r, $v) = $this->extractEntry($v)) && $sub_r) { + $r[$sub_r['key']] = $sub_r['value']; + } + if ($sub_r = $this->x('\}', $v)) $v = $sub_r[1]; + } + /* sub-list */ + elseif ($sub_r = $this->x('\[', $v)) { + $v = $sub_r[1]; + while ((list($sub_r, $v) = $this->extractObject($v)) && $sub_r) { + $r[] = $sub_r; + $v = ltrim($v, ','); + } + if ($sub_r = $this->x('\]', $v)) $v = $sub_r[1]; + } + /* sub-value */ + elseif ((list($sub_r, $v) = $this->extractValue($v)) && ($sub_r !== false)) { + $r = $sub_r; + } + return array($r, $v); + } + + function extractEntry($v) { + if ($r = $this->x('\,', $v)) $v = $r[1]; + /* k */ + if ($r = $this->x('\"([^\"]+)\"\s*\:', $v)) { + $k = $r[1]; + $sub_v = $r[2]; + if (list($sub_r, $sub_v) = $this->extractObject($sub_v)) { + return array( + array('key' => $k, 'value' => $sub_r), + $sub_v + ); + } + } + return array(0, $v); + } + + function extractValue($v) { + if ($r = $this->x('\,', $v)) $v = $r[1]; + if ($sub_r = $this->x('null', $v)) { + return array(null, $sub_r[1]); + } + if ($sub_r = $this->x('(true|false)', $v)) { + return array($sub_r[1], $sub_r[2]); + } + if ($sub_r = $this->x('([\-\+]?[0-9\.]+)', $v)) { + return array($sub_r[1], $sub_r[2]); + } + if ($sub_r = $this->x('\"', $v)) { + $rest = $sub_r[1]; + if (preg_match('/^([^\x5c]*|.*[^\x5c]|.*\x5c{2})\"(.*)$/sU', $rest, $m)) { + $val = $m[1]; + /* unescape chars (single-byte) */ + $val = preg_replace('/\\\u(.{4})/e', 'chr(hexdec("\\1"))', $val); + //$val = preg_replace('/\\\u00(.{2})/e', 'rawurldecode("%\\1")', $val); + /* other escaped chars */ + $from = array('\\\\', '\r', '\t', '\n', '\"', '\b', '\f', '\/'); + $to = array("\\", "\r", "\t", "\n", '"', "\b", "\f", "/"); + $val = str_replace($from, $to, $val); + return array($val, $m[2]); + } + } + return array(false, $v); + } + + /* */ + + function getObject() { + return $this->v('struct', array()); + } + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + function addT($s = '', $p = '', $o = '', $s_type = '', $o_type = '', $o_dt = '', $o_lang = '') { + $o = $this->toUTF8($o); + //echo str_replace($this->base, '', "-----\n adding $s / $p / $o\n-----\n"); + $t = array('s' => $s, 'p' => $p, 'o' => $o, 's_type' => $s_type, 'o_type' => $o_type, 'o_datatype' => $o_dt, 'o_lang' => $o_lang); + if ($this->skip_dupes) { + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + /* */ + +} diff --git a/arc2-2.2.4/parsers/ARC2_LegacyXMLParser.php b/arc2-2.2.4/parsers/ARC2_LegacyXMLParser.php new file mode 100755 index 0000000..3c3564d --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_LegacyXMLParser.php @@ -0,0 +1,311 @@ +encoding = $this->v('encoding', false, $this->a); + $this->state = 0; + $this->x_base = $this->base; + $this->xml = 'http://www.w3.org/XML/1998/namespace'; + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->nsp = array($this->xml => 'xml', $this->rdf => 'rdf'); + $this->allowCDataNodes = 1; + $this->target_encoding = ''; + $this->keep_cdata_ws = $this->v('keep_cdata_whitespace', 0, $this->a); + } + + /* */ + + function setReader(&$reader) { + $this->reader = $reader; + } + + function parse($path, $data = '', $iso_fallback = false) { + $this->nodes = array(); + $this->node_count = 0; + $this->level = 0; + /* reader */ + if (!$this->v('reader')) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->setAcceptHeader('Accept: application/xml; q=0.9, */*; q=0.1'); + $this->reader->activate($path, $data); + $this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base; + $this->base = $this->x_base; + $this->doc_url = $this->reader->base; + /* xml parser */ + $this->initXMLParser(); + /* parse */ + $first = true; + while ($d = $this->reader->readStream(1)) { + if ($iso_fallback && $first) { + $d = '' . "\n" . preg_replace('/^\<\?xml [^\>]+\?\>\s*/s', '', $d); + } + if (!xml_parse($this->xml_parser, $d, false)) { + $error_str = xml_error_string(xml_get_error_code($this->xml_parser)); + $line = xml_get_current_line_number($this->xml_parser); + if (!$iso_fallback && preg_match("/Invalid character/i", $error_str)) { + xml_parser_free($this->xml_parser); + unset($this->xml_parser); + $this->reader->closeStream(); + unset($this->reader); + $this->__init(); + $this->encoding = 'ISO-8859-1'; + $this->initXMLParser(); + return $this->parse($path, $data, true); + } + else { + return $this->addError('XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')'); + } + } + $first = false; + } + $this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING); + xml_parser_free($this->xml_parser); + $this->reader->closeStream(); + unset($this->reader); + return $this->done(); + } + + /* */ + + function getEncoding($src = 'config') { + if ($src == 'parser') { + return $this->target_encoding; + } + elseif (($src == 'config') && $this->encoding) { + return $this->encoding; + } + return $this->reader->getEncoding(); + } + + /* */ + + function done() { + + } + + /* */ + + function getStructure() { + return array('nodes' => $this->v('nodes', array())); + } + + /* */ + + function getNodeIndex(){ + if (!isset($this->node_index)) { + /* index by parent */ + $index = array(); + for ($i = 0, $i_max = count($this->nodes); $i < $i_max; $i++) { + $node = $this->nodes[$i]; + $node['id'] = $i; + $node['doc_base'] = $this->base; + if (isset($this->doc_url)) $node['doc_url'] = $this->doc_url; + $this->updateNode($node); + $p_id = $node['p_id']; + if (!isset($index[$p_id])) { + $index[$p_id] = array(); + } + $index[$p_id][$node['pos']] = $node; + } + $this->node_index = $index; + } + return $this->node_index; + } + + function getNodes() { + return $this->nodes; + } + + function getSubNodes($n) { + return $this->v($n['id'], array(), $this->getNodeIndex()); + } + + function getNodeContent($n, $outer = 0, $trim = 1) { + //echo '
' . htmlspecialchars(print_r($n, 1)) . '
'; + if ($n['tag'] == 'cdata') { + $r = $n['a']['value']; + } + else { + $r = ''; + if ($outer) { + $r .= '<' . $n['tag']; + asort($n['a']); + if (isset($n['a']['xmlns']) && $n['a']['xmlns']['']) { + $r .= ' xmlns="' . $n['a']['xmlns'][''] . '"'; + } + foreach ($n['a'] as $a => $val) { + $r .= preg_match('/^[^\s]+$/', $a) && !is_array($val) ? ' ' . $a . '="' . addslashes($val) . '"' : ''; + } + $r .= $n['empty'] ? '/>' : '>'; + } + if (!$n['empty']) { + $r .= $this->v('cdata', '', $n); + $sub_nodes = $this->getSubNodes($n); + foreach ($sub_nodes as $sub_n) { + $r .= $this->getNodeContent($sub_n, 1, 0); + } + if ($outer) { + $r .= ''; + } + } + } + return ($trim && !$this->keep_cdata_ws) ? trim($r) : $r; + } + + /* */ + + function pushNode($n) { + $n['id'] = $this->node_count; + $this->nodes[$this->node_count] = $n; + $this->node_count++; + } + + function getCurNode($t = '') { + $i = 1; + do { + $r = $this->node_count ? $this->nodes[$this->node_count - $i] : 0; + $found = (!$t || ($r['tag'] == $t)) ? 1 : 0; + $i++; + } while (!$found && isset($this->nodes[$this->node_count - $i])); + return $r; + } + + function updateNode($node) {/* php4-save */ + $this->nodes[$node['id']] = $node; + } + + /* */ + + function initXMLParser() { + if (!isset($this->xml_parser)) { + $enc = preg_match('/^(utf\-8|iso\-8859\-1|us\-ascii)$/i', $this->getEncoding(), $m) ? $m[1] : 'UTF-8'; + $parser = xml_parser_create_ns($enc, ''); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, 'open', 'close'); + xml_set_character_data_handler($parser, 'cData'); + xml_set_start_namespace_decl_handler($parser, 'nsDecl'); + xml_set_object($parser, $this); + $this->xml_parser = $parser; + } + } + + /* */ + + function open($p, $t, $a) { + $t_exact = $t; + //echo "
\n".'opening '.$t . ' ' . print_r($a, 1); flush(); + //echo "
\n".'opening '.$t; flush(); + $t = strpos($t, ':') ? $t : strtolower($t); + /* base check */ + $base = ''; + if (($t == 'base') && isset($a['href'])) { + $this->base = $a['href']; + $base = $a['href']; + } + /* URIs */ + foreach (array('href', 'src', 'id') as $uri_a) { + if (isset($a[$uri_a])) { + $a[$uri_a . ' uri'] = ($uri_a == 'id') ? $this->calcURI('#'.$a[$uri_a]) : $this->calcURI($a[$uri_a]); + } + } + /* ns */ + if ($a) { + foreach ($a as $k => $v) { + if (strpos($k, 'xmlns') === 0) { + $this->nsDecl($p, trim(substr($k, 5), ':'), $v); + } + } + } + /* node */ + $node = array( + 'tag' => $t, + 'tag_exact' => $t_exact, + 'a' => $a, + 'level' => $this->level, + 'pos' => 0, + 'p_id' => $this->node_count-1, + 'state' => 'open', + 'empty' => 0, + 'cdata' =>'' + ); + if ($base) { + $node['base'] = $base; + } + /* parent/sibling */ + if ($this->node_count) { + $l = $this->level; + $prev_node = $this->getCurNode(); + if ($prev_node['level'] == $l) { + $node['p_id'] = $prev_node['p_id']; + $node['pos'] = $prev_node['pos']+1; + } + elseif($prev_node['level'] > $l) { + while($prev_node['level'] > $l) { + if (!isset($this->nodes[$prev_node['p_id']])) { + //$this->addError('nesting mismatch: tag is ' . $t . ', level is ' . $l . ', prev_level is ' . $prev_node['level'] . ', prev_node p_id is ' . $prev_node['p_id']); + break; + } + $prev_node = $this->nodes[$prev_node['p_id']]; + } + $node['p_id'] = $prev_node['p_id']; + $node['pos'] = $prev_node['pos']+1; + } + } + $this->pushNode($node); + $this->level++; + /* cdata */ + $this->cur_cdata=""; + } + + function close($p, $t, $empty = 0) { + //echo "
\n".'closing '.$t; flush(); + $node = $this->getCurNode($t); + $node['state'] = 'closed'; + $node['empty'] = $empty; + $this->updateNode($node); + $this->level--; + } + + function cData($p, $d) { + //echo trim($d) ? "
\n".'cdata: ' . $d : ''; flush(); + $node = $this->getCurNode(); + if($node['state'] == 'open') { + $node['cdata'] .= $d; + $this->updateNode($node); + } + else {/* cdata is sibling of node */ + if ($this->allowCDataNodes) { + $this->open($p, 'cdata', array('value' => $d)); + $this->close($p, 'cdata'); + } + } + } + + function nsDecl($p, $prf, $uri) { + if (is_array($uri)) return 1; + $this->ns[$prf] = $uri; + $this->nsp[$uri] = isset($this->nsp[$uri]) ? $this->nsp[$uri] : $prf; + } + + /* */ + +} \ No newline at end of file diff --git a/arc2-2.2.4/parsers/ARC2_RDFParser.php b/arc2-2.2.4/parsers/ARC2_RDFParser.php new file mode 100755 index 0000000..44dd778 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_RDFParser.php @@ -0,0 +1,139 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_RDFParser extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* proxy_host, proxy_port, proxy_skip, http_accept_header, http_user_agent_header, max_redirects, reader, skip_dupes */ + parent::__init(); + $this->a['format'] = $this->v('format', false, $this->a); + $this->keep_time_limit = $this->v('keep_time_limit', 0, $this->a); + $this->triples = array(); + $this->t_count = 0; + $this->added_triples = array(); + $this->skip_dupes = $this->v('skip_dupes', false, $this->a); + $this->bnode_prefix = $this->v('bnode_prefix', 'arc'.substr(md5(uniqid(rand())), 0, 4).'b', $this->a); + $this->bnode_id = 0; + $this->format = ''; + } + + /* */ + + function setReader(&$reader) { + $this->reader = $reader; + } + + function parse($path, $data = '') { + /* reader */ + if (!isset($this->reader)) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->activate($path, $data) ; + /* format detection */ + $mappings = array( + 'rdfxml' => 'RDFXML', + 'turtle' => 'Turtle', + 'sparqlxml' => 'SPOG', + 'ntriples' => 'Turtle', + 'html' => 'SemHTML', + 'rss' => 'RSS', + 'atom' => 'Atom', + 'sgajson' => 'SGAJSON', + 'cbjson' => 'CBJSON' + ); + $format = $this->reader->getFormat(); + if (!$format || !isset($mappings[$format])) { + return $this->addError('No parser available for "' . $format . '".'); + } + $this->format = $format; + /* format parser */ + $suffix = $mappings[$format] . 'Parser'; + ARC2::inc($suffix); + $cls = 'ARC2_' . $suffix; + $this->parser = new $cls($this->a, $this); + $this->parser->setReader($this->reader); + return $this->parser->parse($path, $data); + } + + function parseData($data) { + return $this->parse(ARC2::getScriptURI(), $data); + } + + /* */ + + function done() { + } + + /* */ + + function createBnodeID(){ + $this->bnode_id++; + return '_:' . $this->bnode_prefix . $this->bnode_id; + } + + function getTriples() { + return $this->v('parser') ? $this->m('getTriples', false, array(), $this->v('parser')) : array(); + } + + function countTriples() { + return $this->v('parser') ? $this->m('countTriples', false, 0, $this->v('parser')) : 0; + } + + function getSimpleIndex($flatten_objects = 1, $vals = '') { + return ARC2::getSimpleIndex($this->getTriples(), $flatten_objects, $vals); + } + + function reset() { + $this->__init(); + if (isset($this->reader)) unset($this->reader); + if (isset($this->parser)) { + $this->parser->__init(); + unset($this->parser); + } + } + + /* */ + + function extractRDF($formats = '') { + if (method_exists($this->parser, 'extractRDF')) { + return $this->parser->extractRDF($formats); + } + } + + /* */ + + function getEncoding($src = 'config') { + if (method_exists($this->parser, 'getEncoding')) { + return $this->parser->getEncoding($src); + } + } + + /** + * returns the array of namespace prefixes encountered during parsing + * @return array (keys = namespace URI / values = prefix used) + */ + + function getParsedNamespacePrefixes() { + if (isset($this->parser)) { + return $this->v('nsp', array(), $this->parser); + } + return $this->v('nsp', array()); + } + + /* */ + +} diff --git a/arc2-2.2.4/parsers/ARC2_RDFXMLParser.php b/arc2-2.2.4/parsers/ARC2_RDFXMLParser.php new file mode 100755 index 0000000..f66a0e4 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_RDFXMLParser.php @@ -0,0 +1,640 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 +*/ + +ARC2::inc('RDFParser'); + +class ARC2_RDFXMLParser extends ARC2_RDFParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* reader */ + parent::__init(); + $this->encoding = $this->v('encoding', false, $this->a); + $this->state = 0; + $this->x_lang = ''; + $this->x_base = $this->base; + $this->xml = 'http://www.w3.org/XML/1998/namespace'; + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->nsp = array($this->xml => 'xml', $this->rdf => 'rdf'); + $this->s_stack = array(); + $this->s_count = 0; + $this->target_encoding = ''; + } + + /* */ + + function parse($path, $data = '', $iso_fallback = false) { + /* reader */ + if (!$this->v('reader')) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->setAcceptHeader('Accept: application/rdf+xml; q=0.9, */*; q=0.1'); + $this->reader->activate($path, $data); + $this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base; + /* xml parser */ + $this->initXMLParser(); + /* parse */ + $first = true; + while ($d = $this->reader->readStream()) { + if (!$this->keep_time_limit) @set_time_limit($this->v('time_limit', 60, $this->a)); + if ($iso_fallback && $first) { + $d = '' . "\n" . preg_replace('/^\<\?xml [^\>]+\?\>\s*/s', '', $d); + $first = false; + } + if (!xml_parse($this->xml_parser, $d, false)) { + $error_str = xml_error_string(xml_get_error_code($this->xml_parser)); + $line = xml_get_current_line_number($this->xml_parser); + $this->tmp_error = 'XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')'; + if (!$iso_fallback && preg_match("/Invalid character/i", $error_str)) { + xml_parser_free($this->xml_parser); + unset($this->xml_parser); + $this->reader->closeStream(); + $this->__init(); + $this->encoding = 'ISO-8859-1'; + unset($this->xml_parser); + unset($this->reader); + return $this->parse($path, $data, true); + } + else { + return $this->addError($this->tmp_error); + } + } + } + $this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING); + xml_parser_free($this->xml_parser); + $this->reader->closeStream(); + unset($this->reader); + return $this->done(); + } + + /* */ + + function initXMLParser() { + if (!isset($this->xml_parser)) { + $enc = preg_match('/^(utf\-8|iso\-8859\-1|us\-ascii)$/i', $this->getEncoding(), $m) ? $m[1] : 'UTF-8'; + $parser = xml_parser_create_ns($enc, ''); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, 'open', 'close'); + xml_set_character_data_handler($parser, 'cdata'); + xml_set_start_namespace_decl_handler($parser, 'nsDecl'); + xml_set_object($parser, $this); + $this->xml_parser = $parser; + } + } + + /* */ + + function getEncoding($src = 'config') { + if ($src == 'parser') { + return $this->target_encoding; + } + elseif (($src == 'config') && $this->encoding) { + return $this->encoding; + } + return $this->reader->getEncoding(); + } + + /* */ + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + /* */ + + function pushS(&$s) { + $s['pos'] = $this->s_count; + $this->s_stack[$this->s_count] = $s; + $this->s_count++; + } + + function popS(){/* php 4.0.x-safe */ + $r = array(); + $this->s_count--; + for ($i = 0, $i_max = $this->s_count; $i < $i_max; $i++) { + $r[$i] = $this->s_stack[$i]; + } + $this->s_stack = $r; + } + + function updateS($s) { + $this->s_stack[$s['pos']] = $s; + } + + function getParentS() { + return ($this->s_count && isset($this->s_stack[$this->s_count - 1])) ? $this->s_stack[$this->s_count - 1] : false; + } + + function getParentXBase() { + if ($p = $this->getParentS()) { + return isset($p['p_x_base']) && $p['p_x_base'] ? $p['p_x_base'] : (isset($p['x_base']) ? $p['x_base'] : ''); + } + return $this->x_base; + } + + function getParentXLang() { + if ($p = $this->getParentS()) { + return isset($p['p_x_lang']) && $p['p_x_lang'] ? $p['p_x_lang'] : (isset($p['x_lang']) ? $p['x_lang'] : ''); + } + return $this->x_lang; + } + + /* */ + + function addT($s, $p, $o, $s_type, $o_type, $o_dt = '', $o_lang = '') { + //echo "-----\nadding $s / $p / $o\n-----\n"; + $t = array('s' => $s, 'p' => $p, 'o' => $o, 's_type' => $s_type, 'o_type' => $o_type, 'o_datatype' => $o_dt, 'o_lang' => $o_lang); + if ($this->skip_dupes) { + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + function reify($t, $s, $p, $o, $s_type, $o_type, $o_dt = '', $o_lang = '') { + $this->addT($t, $this->rdf.'type', $this->rdf.'Statement', 'uri', 'uri'); + $this->addT($t, $this->rdf.'subject', $s, 'uri', $s_type); + $this->addT($t, $this->rdf.'predicate', $p, 'uri', 'uri'); + $this->addT($t, $this->rdf.'object', $o, 'uri', $o_type, $o_dt, $o_lang); + } + + /* */ + + function open($p, $t, $a) { + //echo "state is $this->state\n"; + //echo "opening $t\n"; + switch($this->state) { + case 0: return $this->h0Open($t, $a); + case 1: return $this->h1Open($t, $a); + case 2: return $this->h2Open($t, $a); + case 4: return $this->h4Open($t, $a); + case 5: return $this->h5Open($t, $a); + case 6: return $this->h6Open($t, $a); + default: $this->addError('open() called at state ' . $this->state . ' in '.$t); + } + } + + function close($p, $t) { + //echo "state is $this->state\n"; + //echo "closing $t\n"; + switch($this->state){ + case 1: return $this->h1Close($t); + case 2: return $this->h2Close($t); + case 3: return $this->h3Close($t); + case 4: return $this->h4Close($t); + case 5: return $this->h5Close($t); + case 6: return $this->h6Close($t); + default: $this->addError('close() called at state ' . $this->state . ' in '.$t); + } + } + + function cdata($p, $d) { + //echo "state is $this->state\n"; + //echo "cdata\n"; + switch($this->state){ + case 4: return $this->h4Cdata($d); + case 6: return $this->h6Cdata($d); + default: return false; + } + } + + function nsDecl($p, $prf, $uri) { + $this->nsp[$uri] = isset($this->nsp[$uri]) ? $this->nsp[$uri] : $prf; + } + + /* */ + + function h0Open($t, $a) { + $this->x_lang = $this->v($this->xml.'lang', $this->x_lang, $a); + $this->x_base = $this->calcURI($this->v($this->xml.'base', $this->x_base, $a)); + $this->state = 1; + if ($t !== $this->rdf.'RDF') { + $this->h1Open($t, $a); + } + } + + /* */ + + function h1Open($t, $a) { + $s = array( + 'x_base' => isset($a[$this->xml.'base']) ? $this->calcURI($a[$this->xml.'base']) : $this->getParentXBase(), + 'x_lang' => isset($a[$this->xml.'lang']) ? $a[$this->xml.'lang'] : $this->getParentXLang(), + 'li_count' => 0, + ); + /* ID */ + if (isset($a[$this->rdf.'ID'])) { + $s['type'] = 'uri'; + $s['value'] = $this->calcURI('#'.$a[$this->rdf.'ID'], $s['x_base']); + } + /* about */ + elseif (isset($a[$this->rdf.'about'])) { + $s['type'] = 'uri'; + $s['value'] = $this->calcURI($a[$this->rdf.'about'], $s['x_base']); + } + /* bnode */ + else { + $s['type'] = 'bnode'; + if (isset($a[$this->rdf.'nodeID'])) { + $s['value'] = '_:'.$a[$this->rdf.'nodeID']; + } + else { + $s['value'] = $this->createBnodeID(); + } + } + /* sub-node */ + if ($this->state === 4) { + $sup_s = $this->getParentS(); + /* new collection */ + if (isset($sup_s['o_is_coll']) && $sup_s['o_is_coll']) { + $coll = array('value' => $this->createBnodeID(), 'type' => 'bnode', 'is_coll' => true, 'x_base' => $s['x_base'], 'x_lang' => $s['x_lang']); + $this->addT($sup_s['value'], $sup_s['p'], $coll['value'], $sup_s['type'], $coll['type']); + $this->addT($coll['value'], $this->rdf . 'first', $s['value'], $coll['type'], $s['type']); + $this->pushS($coll); + } + /* new entry in existing coll */ + elseif (isset($sup_s['is_coll']) && $sup_s['is_coll']) { + $coll = array('value' => $this->createBnodeID(), 'type' => 'bnode', 'is_coll' => true, 'x_base' => $s['x_base'], 'x_lang' => $s['x_lang']); + $this->addT($sup_s['value'], $this->rdf . 'rest', $coll['value'], $sup_s['type'], $coll['type']); + $this->addT($coll['value'], $this->rdf . 'first', $s['value'], $coll['type'], $s['type']); + $this->pushS($coll); + } + /* normal sub-node */ + elseif(isset($sup_s['p']) && $sup_s['p']) { + $this->addT($sup_s['value'], $sup_s['p'], $s['value'], $sup_s['type'], $s['type']); + } + } + /* typed node */ + if ($t !== $this->rdf.'Description') { + $this->addT($s['value'], $this->rdf.'type', $t, $s['type'], 'uri'); + } + /* (additional) typing attr */ + if (isset($a[$this->rdf.'type'])) { + $this->addT($s['value'], $this->rdf.'type', $a[$this->rdf.'type'], $s['type'], 'uri'); + } + /* Seq|Bag|Alt */ + if (in_array($t, array($this->rdf.'Seq', $this->rdf.'Bag', $this->rdf.'Alt'))) { + $s['is_con'] = true; + } + /* any other attrs (skip rdf and xml, except rdf:_, rdf:value, rdf:Seq) */ + foreach($a as $k => $v) { + if (((strpos($k, $this->xml) === false) && (strpos($k, $this->rdf) === false)) || preg_match('/(\_[0-9]+|value|Seq|Bag|Alt|Statement|Property|List)$/', $k)) { + if (strpos($k, ':')) { + $this->addT($s['value'], $k, $v, $s['type'], 'literal', '', $s['x_lang']); + } + } + } + $this->pushS($s); + $this->state = 2; + } + + /* */ + + function h2Open($t, $a) { + $s = $this->getParentS(); + foreach (array('p_x_base', 'p_x_lang', 'p_id', 'o_is_coll') as $k) { + unset($s[$k]); + } + /* base */ + if (isset($a[$this->xml.'base'])) { + $s['p_x_base'] = $this->calcURI($a[$this->xml.'base'], $s['x_base']); + } + $b = isset($s['p_x_base']) && $s['p_x_base'] ? $s['p_x_base'] : $s['x_base']; + /* lang */ + if (isset($a[$this->xml.'lang'])) { + $s['p_x_lang'] = $a[$this->xml.'lang']; + } + $l = isset($s['p_x_lang']) && $s['p_x_lang'] ? $s['p_x_lang'] : $s['x_lang']; + /* adjust li */ + if ($t === $this->rdf.'li') { + $s['li_count']++; + $t = $this->rdf.'_'.$s['li_count']; + } + /* set p */ + $s['p'] = $t; + /* reification */ + if (isset($a[$this->rdf.'ID'])) { + $s['p_id'] = $a[$this->rdf.'ID']; + } + $o = array('value' => '', 'type' => '', 'x_base' => $b, 'x_lang' => $l); + /* resource/rdf:resource */ + if (isset($a['resource'])) { + $a[$this->rdf . 'resource'] = $a['resource']; + unset($a['resource']); + } + if (isset($a[$this->rdf.'resource'])) { + $o['value'] = $this->calcURI($a[$this->rdf.'resource'], $b); + $o['type'] = 'uri'; + $this->addT($s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + /* type */ + if (isset($a[$this->rdf.'type'])) { + $this->addT($o['value'], $this->rdf.'type', $a[$this->rdf.'type'], 'uri', 'uri'); + } + /* reification */ + if (isset($s['p_id'])) { + $this->reify($this->calcURI('#'.$s['p_id'], $b), $s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + unset($s['p_id']); + } + $this->state = 3; + } + /* named bnode */ + elseif (isset($a[$this->rdf.'nodeID'])) { + $o['value'] = '_:' . $a[$this->rdf.'nodeID']; + $o['type'] = 'bnode'; + $this->addT($s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + $this->state = 3; + /* reification */ + if (isset($s['p_id'])) { + $this->reify($this->calcURI('#'.$s['p_id'], $b), $s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + } + } + /* parseType */ + elseif (isset($a[$this->rdf.'parseType'])) { + if ($a[$this->rdf.'parseType'] === 'Literal') { + $s['o_xml_level'] = 0; + $s['o_xml_data'] = ''; + $s['p_xml_literal_level'] = 0; + $s['ns'] = array(); + $this->state = 6; + } + elseif ($a[$this->rdf.'parseType'] === 'Resource') { + $o['value'] = $this->createBnodeID(); + $o['type'] = 'bnode'; + $o['has_closing_tag'] = 0; + $this->addT($s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + $this->pushS($o); + /* reification */ + if (isset($s['p_id'])) { + $this->reify($this->calcURI('#'.$s['p_id'], $b), $s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + unset($s['p_id']); + } + $this->state = 2; + } + elseif ($a[$this->rdf.'parseType'] === 'Collection') { + $s['o_is_coll'] = true; + $this->state = 4; + } + } + /* sub-node or literal */ + else { + $s['o_cdata'] = ''; + if (isset($a[$this->rdf.'datatype'])) { + $s['o_datatype'] = $a[$this->rdf.'datatype']; + } + $this->state = 4; + } + /* any other attrs (skip rdf and xml) */ + foreach($a as $k => $v) { + if (((strpos($k, $this->xml) === false) && (strpos($k, $this->rdf) === false)) || preg_match('/(\_[0-9]+|value)$/', $k)) { + if (strpos($k, ':')) { + if (!$o['value']) { + $o['value'] = $this->createBnodeID(); + $o['type'] = 'bnode'; + $this->addT($s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + } + /* reification */ + if (isset($s['p_id'])) { + $this->reify($this->calcURI('#'.$s['p_id'], $b), $s['value'], $s['p'], $o['value'], $s['type'], $o['type']); + unset($s['p_id']); + } + $this->addT($o['value'], $k, $v, $o['type'], 'literal'); + $this->state = 3; + } + } + } + $this->updateS($s); + } + + /* */ + + function h4Open($t, $a) { + return $this->h1Open($t, $a); + } + + /* */ + + function h5Open($t, $a) { + $this->state = 4; + return $this->h4Open($t, $a); + } + + /* */ + + function h6Open($t, $a) { + $s = $this->getParentS(); + $data = isset($s['o_xml_data']) ? $s['o_xml_data'] : ''; + $ns = isset($s['ns']) ? $s['ns'] : array(); + $parts = $this->splitURI($t); + if ((count($parts) === 1) || empty($parts[1])) { + $data .= '<'.$t; + } + else { + $ns_uri = $parts[0]; + $name = $parts[1]; + if (!isset($this->nsp[$ns_uri])) { + foreach ($this->nsp as $tmp1 => $tmp2) { + if (strpos($t, $tmp1) === 0) { + $ns_uri = $tmp1; + $name = substr($t, strlen($tmp1)); + break; + } + } + } + $nsp = $this->nsp[$ns_uri]; + $data .= $nsp ? '<' . $nsp . ':' . $name : '<' . $name; + /* ns */ + if (!isset($ns[$nsp.'='.$ns_uri]) || !$ns[$nsp.'='.$ns_uri]) { + $data .= $nsp ? ' xmlns:'.$nsp.'="'.$ns_uri.'"' : ' xmlns="'.$ns_uri.'"'; + $ns[$nsp.'='.$ns_uri] = true; + $s['ns'] = $ns; + } + } + foreach ($a as $k => $v) { + $parts = $this->splitURI($k); + if (count($parts) === 1) { + $data .= ' '.$k.'="'.$v.'"'; + } + else { + $ns_uri = $parts[0]; + $name = $parts[1]; + $nsp = $this->v($ns_uri, '', $this->nsp); + $data .= $nsp ? ' '.$nsp.':'.$name.'="'.$v.'"' : ' '.$name.'="'.$v.'"' ; + } + } + $data .= '>'; + $s['o_xml_data'] = $data; + $s['o_xml_level'] = isset($s['o_xml_level']) ? $s['o_xml_level'] + 1 : 1; + if ($t == $s['p']) {/* xml container prop */ + $s['p_xml_literal_level'] = isset($s['p_xml_literal_level']) ? $s['p_xml_literal_level'] + 1 : 1; + } + $this->updateS($s); + } + + /* */ + + function h1Close($t) {/* end of doc */ + $this->state = 0; + } + + /* */ + + function h2Close($t) {/* expecting a prop, getting a close */ + if ($s = $this->getParentS()) { + $has_closing_tag = (isset($s['has_closing_tag']) && !$s['has_closing_tag']) ? 0 : 1; + $this->popS(); + $this->state = 5; + if ($s = $this->getParentS()) {/* new s */ + if (!isset($s['p']) || !$s['p']) {/* p close after collection|parseType=Resource|node close after p close */ + $this->state = $this->s_count ? 4 : 1; + if (!$has_closing_tag) { + $this->state = 2; + } + } + elseif (!$has_closing_tag) { + $this->state = 2; + } + } + } + } + + /* */ + + function h3Close($t) {/* p close */ + $this->state = 2; + } + + /* */ + + function h4Close($t) {/* empty p | pClose after cdata | pClose after collection */ + if ($s = $this->getParentS()) { + $b = isset($s['p_x_base']) && $s['p_x_base'] ? $s['p_x_base'] : (isset($s['x_base']) ? $s['x_base'] : ''); + if (isset($s['is_coll']) && $s['is_coll']) { + $this->addT($s['value'], $this->rdf . 'rest', $this->rdf . 'nil', $s['type'], 'uri'); + /* back to collection start */ + while ((!isset($s['p']) || ($s['p'] != $t))) { + $sub_s = $s; + $this->popS(); + $s = $this->getParentS(); + } + /* reification */ + if (isset($s['p_id']) && $s['p_id']) { + $this->reify($this->calcURI('#'.$s['p_id'], $b), $s['value'], $s['p'], $sub_s['value'], $s['type'], $sub_s['type']); + } + unset($s['p']); + $this->updateS($s); + } + else { + $dt = isset($s['o_datatype']) ? $s['o_datatype'] : ''; + $l = isset($s['p_x_lang']) && $s['p_x_lang'] ? $s['p_x_lang'] : (isset($s['x_lang']) ? $s['x_lang'] : ''); + $o = array('type' => 'literal', 'value' => $s['o_cdata']); + $this->addT($s['value'], $s['p'], $o['value'], $s['type'], $o['type'], $dt, $l); + /* reification */ + if (isset($s['p_id']) && $s['p_id']) { + $this->reify($this->calcURI('#'.$s['p_id'], $b), $s['value'], $s['p'], $o['value'], $s['type'], $o['type'], $dt, $l); + } + unset($s['o_cdata']); + unset($s['o_datatype']); + unset($s['p']); + $this->updateS($s); + } + $this->state = 2; + } + } + + /* */ + + function h5Close($t) {/* p close */ + if ($s = $this->getParentS()) { + unset($s['p']); + $this->updateS($s); + $this->state = 2; + } + } + + /* */ + + function h6Close($t) { + if ($s = $this->getParentS()) { + $l = isset($s['p_x_lang']) && $s['p_x_lang'] ? $s['p_x_lang'] : (isset($s['x_lang']) ? $s['x_lang'] : ''); + $data = $s['o_xml_data']; + $level = $s['o_xml_level']; + if ($level === 0) {/* pClose */ + $this->addT($s['value'], $s['p'], trim($data, ' '), $s['type'], 'literal', $this->rdf.'XMLLiteral', $l); + unset($s['o_xml_data']); + $this->state = 2; + } + else { + $parts = $this->splitURI($t); + if ((count($parts) === 1) || empty($parts[1])) { + $data .= ''; + } + else { + $ns_uri = $parts[0]; + $name = $parts[1]; + if (!isset($this->nsp[$ns_uri])) { + foreach ($this->nsp as $tmp1 => $tmp2) { + if (strpos($t, $tmp1) === 0) { + $ns_uri = $tmp1; + $name = substr($t, strlen($tmp1)); + break; + } + } + } + $nsp = $this->nsp[$ns_uri]; + $data .= $nsp ? '' : ''; + } + $s['o_xml_data'] = $data; + $s['o_xml_level'] = $level - 1; + if ($t == $s['p']) {/* xml container prop */ + $s['p_xml_literal_level']--; + } + } + $this->updateS($s); + } + } + + /* */ + + function h4Cdata($d) { + if ($s = $this->getParentS()) { + $s['o_cdata'] = isset($s['o_cdata']) ? $s['o_cdata'] . $d : $d; + $this->updateS($s); + } + } + + /* */ + + function h6Cdata($d) { + if ($s = $this->getParentS()) { + if (isset($s['o_xml_data']) || preg_match("/[\n\r]/", $d) || trim($d)) { + $d = htmlspecialchars($d, ENT_NOQUOTES); + $s['o_xml_data'] = isset($s['o_xml_data']) ? $s['o_xml_data'] . $d : $d; + } + $this->updateS($s); + } + } + + /* */ + +} diff --git a/arc2-2.2.4/parsers/ARC2_RSSParser.php b/arc2-2.2.4/parsers/ARC2_RSSParser.php new file mode 100755 index 0000000..cf21e69 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_RSSParser.php @@ -0,0 +1,185 @@ +triples = array(); + $this->target_encoding = ''; + $this->t_count = 0; + $this->added_triples = array(); + $this->skip_dupes = false; + $this->bnode_prefix = $this->v('bnode_prefix', 'arc'.substr(md5(uniqid(rand())), 0, 4).'b', $this->a); + $this->bnode_id = 0; + $this->cache = array(); + $this->allowCDataNodes = 0; + } + + /* */ + + function done() { + $this->extractRDF(); + } + + /* */ + + function setReader(&$reader) { + $this->reader = $reader; + } + + function createBnodeID(){ + $this->bnode_id++; + return '_:' . $this->bnode_prefix . $this->bnode_id; + } + + function addT($t) { + //if (!isset($t['o_datatype'])) + if ($this->skip_dupes) { + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + function getSimpleIndex($flatten_objects = 1, $vals = '') { + return ARC2::getSimpleIndex($this->getTriples(), $flatten_objects, $vals); + } + + /* */ + + function extractRDF() { + $index = $this->getNodeIndex(); + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->rss = 'http://purl.org/rss/1.0/'; + $this->dc = 'http://purl.org/dc/elements/1.1/'; + $this->dct = 'http://purl.org/dc/terms/'; + $this->content = 'http://purl.org/rss/1.0/modules/content/'; + $this->enc = 'http://purl.oclc.org/net/rss_2.0/enc#'; + $this->mappings = array( + 'channel' => $this->rss . 'channel', + 'item' => $this->rss . 'item', + 'title' => $this->rss . 'title', + 'link' => $this->rss . 'link', + 'description' => $this->rss . 'description', + 'guid' => $this->dc . 'identifier', + 'author' => $this->dc . 'creator', + 'category' => $this->dc . 'subject', + 'pubDate' => $this->dc . 'date', + 'pubdate' => $this->dc . 'date', + 'source' => $this->dc . 'source', + 'enclosure' => $this->enc . 'enclosure', + ); + $this->dt_props = array( + $this->dc . 'identifier', + $this->rss . 'link' + ); + foreach ($index as $p_id => $nodes) { + foreach ($nodes as $pos => $node) { + $tag = $this->v('tag', '', $node); + if ($tag == 'channel') { + $struct = $this->extractChannel($index[$node['id']]); + $triples = ARC2::getTriplesFromIndex($struct); + foreach ($triples as $t) { + $this->addT($t); + } + } + elseif ($tag == 'item') { + $struct = $this->extractItem($index[$node['id']]); + $triples = ARC2::getTriplesFromIndex($struct); + foreach ($triples as $t) { + $this->addT($t); + } + } + } + } + } + + function extractChannel($els) { + $res = array($this->rdf . 'type' => array(array('value' => $this->rss . 'channel', 'type' => 'uri'))); + $res = array_merge($res, $this->extractProps($els, 'channel')); + return array($res[$this->rss . 'link'][0]['value'] => $res); + } + + function extractItem($els) { + $res = array($this->rdf . 'type' => array(array('value' => $this->rss . 'item', 'type' => 'uri'))); + $res = array_merge($res, $this->extractProps($els, 'item')); + if (isset($res[$this->rss . 'link'])) return array($res[$this->rss . 'link'][0]['value'] => $res); + if (isset($res[$this->dc . 'identifier'])) return array($res[$this->dc . 'identifier'][0]['value'] => $res); + } + + function extractProps($els, $container) { + $res = array(); + foreach ($els as $info) { + /* key */ + $tag = $info['tag']; + if (!preg_match('/^[a-z0-9]+\:/i', $tag)) { + $k = isset($this->mappings[$tag]) ? $this->mappings[$tag] : ''; + } + else { + $k = $tag; + } + if (($container == 'channel') && ($k == $this->rss . 'item')) continue; + /* val */ + $v = $info['cdata']; + if (!$v) $v = $this->v('url', '', $info['a']); + if (!$v) $v = $this->v('href', '', $info['a']); + /* prop */ + if ($k) { + /* enclosure handling */ + if ($k == $this->enc . 'enclosure') { + $sub_res = array(); + foreach (array('length', 'type') as $attr) { + if ($attr_v = $this->v($attr, 0, $info['a'])) { + $sub_res[$this->enc . $attr] = array(array('value' => $attr_v, 'type' => 'literal')); + } + } + $struct[$v] = $sub_res; + } + /* date handling */ + if (in_array($k, array($this->dc . 'date', $this->dct . 'modified'))) { + if (!preg_match('/^[0-9]{4}/', $v) && ($sub_v = strtotime($v)) && ($sub_v != -1)) { + $tz = date('Z', $sub_v); /* timezone offset */ + $sub_v -= $tz; /* utc */ + $v = date('Y-m-d\TH:i:s\Z', $sub_v); + } + } + if (!isset($res[$k])) $res[$k] = array(); + $res[$k][] = array('value' => $v, 'type' => in_array($k, $this->dt_props) || !preg_match('/^[a-z0-9]+\:[^\s]+$/is', $v) ? 'literal' : 'uri'); + } + } + return $res; + } + + /* */ + + +} diff --git a/arc2-2.2.4/parsers/ARC2_SGAJSONParser.php b/arc2-2.2.4/parsers/ARC2_SGAJSONParser.php new file mode 100755 index 0000000..d418123 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_SGAJSONParser.php @@ -0,0 +1,63 @@ +rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->nsp = array($this->rdf => 'rdf'); + } + + /* */ + + function done() { + $this->extractRDF(); + } + + function extractRDF() { + $s = $this->getContext(); + $os = $this->getURLs($this->struct); + foreach ($os as $o) { + if ($o != $s) $this->addT($s, 'http://www.w3.org/2000/01/rdf-schema#seeAlso', $o, 'uri', 'uri'); + } + } + + function getContext() { + if (!isset($this->struct['canonical_mapping'])) return ''; + foreach ($this->struct['canonical_mapping'] as $k => $v) return $v; + } + + function getURLs($struct) { + $r =array(); + if (is_array($struct)) { + foreach ($struct as $k => $v) { + if (preg_match('/^http:\/\//', $k) && !in_array($k, $r)) $r[] = $k; + $sub_r = $this->getURLs($v); + foreach ($sub_r as $sub_v) { + if (!in_array($sub_v, $r)) $r[] = $sub_v; + } + } + } + elseif (preg_match('/^http:\/\//', $struct) && !in_array($struct, $r)) { + $r[] = $struct; + } + return $r; + } + + /* */ + +} diff --git a/arc2-2.2.4/parsers/ARC2_SPARQLParser.php b/arc2-2.2.4/parsers/ARC2_SPARQLParser.php new file mode 100755 index 0000000..401e20d --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_SPARQLParser.php @@ -0,0 +1,777 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('TurtleParser'); + +class ARC2_SPARQLParser extends ARC2_TurtleParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->bnode_prefix = $this->v('bnode_prefix', 'arc'.substr(md5(uniqid(rand())), 0, 4).'b', $this->a); + $this->bnode_id = 0; + $this->bnode_pattern_index = array('patterns' => array(), 'bnodes' => array()); + } + + /* */ + + function parse($q, $src = '', $iso_fallback = 'ignore') { + $this->setDefaultPrefixes(); + $this->base = $src ? $this->calcBase($src) : ARC2::getRequestURI(); + $this->r = array( + 'base' => '', + 'vars' => array(), + 'prefixes' => array() + ); + $this->unparsed_code = $q; + list($r, $v) = $this->xQuery($q); + if ($r) { + $this->r['query'] = $r; + $this->unparsed_code = trim($v); + } + elseif (!$this->getErrors() && !$this->unparsed_code) { + $this->addError('Query not properly closed'); + } + $this->r['prefixes'] = $this->prefixes; + $this->r['base'] = $this->base; + /* remove trailing comments */ + while (preg_match('/^\s*(\#[^\xd\xa]*)(.*)$/si', $this->unparsed_code, $m)) $this->unparsed_code = $m[2]; + if ($this->unparsed_code && !$this->getErrors()) { + $rest = preg_replace('/[\x0a|\x0d]/i', ' ', substr($this->unparsed_code, 0, 30)); + $msg = trim($rest) ? 'Could not properly handle "' . $rest . '"' : 'Syntax error, probably an incomplete pattern'; + $this->addError($msg); + } + } + + function getQueryInfos() { + return $this->v('r', array()); + } + + /* 1 */ + + function xQuery($v) { + list($r, $v) = $this->xPrologue($v); + foreach (array('Select', 'Construct', 'Describe', 'Ask') as $type) { + $m = 'x' . $type . 'Query'; + if ((list($r, $v) = $this->$m($v)) && $r) { + return array($r, $v); + } + } + return array(0, $v); + } + + /* 2 */ + + function xPrologue($v) { + $r = 0; + if ((list($sub_r, $v) = $this->xBaseDecl($v)) && $sub_r) { + $this->base = $sub_r; + $r = 1; + } + while ((list($sub_r, $v) = $this->xPrefixDecl($v)) && $sub_r) { + $this->prefixes[$sub_r['prefix']] = $sub_r['uri']; + $r = 1; + } + return array($r, $v); + } + + /* 5.. */ + + function xSelectQuery($v) { + if ($sub_r = $this->x('SELECT\s+', $v)) { + $r = array( + 'type' => 'select', + 'result_vars' => array(), + 'dataset' => array(), + ); + $all_vars = 0; + $sub_v = $sub_r[1]; + /* distinct, reduced */ + if ($sub_r = $this->x('(DISTINCT|REDUCED)\s+', $sub_v)) { + $r[strtolower($sub_r[1])] = 1; + $sub_v = $sub_r[2]; + } + /* result vars */ + if ($sub_r = $this->x('\*\s+', $sub_v)) { + $all_vars = 1; + $sub_v = $sub_r[1]; + } + else { + while ((list($sub_r, $sub_v) = $this->xResultVar($sub_v)) && $sub_r) { + $r['result_vars'][] = $sub_r; + } + } + if (!$all_vars && !count($r['result_vars'])) { + $this->addError('No result bindings specified.'); + } + /* dataset */ + while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { + $r['dataset'][] = $sub_r; + } + /* where */ + if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { + $r['pattern'] = $sub_r; + } + else { + return array(0, $v); + } + /* solution modifier */ + if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + /* all vars */ + if ($all_vars) { + foreach ($this->r['vars'] as $var) { + $r['result_vars'][] = array('var' => $var, 'aggregate' => 0, 'alias' => ''); + } + if (!$r['result_vars']) { + $r['result_vars'][] = '*'; + } + } + return array($r, $sub_v); + } + return array(0, $v); + } + + function xResultVar($v) { + return $this->xVar($v); + } + + /* 6.. */ + + function xConstructQuery($v) { + if ($sub_r = $this->x('CONSTRUCT\s*', $v)) { + $r = array( + 'type' => 'construct', + 'dataset' => array(), + ); + $sub_v = $sub_r[1]; + /* construct template */ + if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { + $r['construct_triples'] = $sub_r; + } + else { + $this->addError('Construct Template not found'); + return array(0, $v); + } + /* dataset */ + while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { + $r['dataset'][] = $sub_r; + } + /* where */ + if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { + $r['pattern'] = $sub_r; + } + else { + return array(0, $v); + } + /* solution modifier */ + if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + return array($r, $sub_v); + } + return array(0, $v); + } + + /* 7.. */ + + function xDescribeQuery($v) { + if ($sub_r = $this->x('DESCRIBE\s+', $v)) { + $r = array( + 'type' => 'describe', + 'result_vars' => array(), + 'result_uris' => array(), + 'dataset' => array(), + ); + $sub_v = $sub_r[1]; + $all_vars = 0; + /* result vars/uris */ + if ($sub_r = $this->x('\*\s+', $sub_v)) { + $all_vars = 1; + $sub_v = $sub_r[1]; + } + else { + do { + $proceed = 0; + if ((list($sub_r, $sub_v) = $this->xResultVar($sub_v)) && $sub_r) { + $r['result_vars'][] = $sub_r; + $proceed = 1; + } + if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { + $r['result_uris'][] = $sub_r; + $proceed =1; + } + } while ($proceed); + } + if (!$all_vars && !count($r['result_vars']) && !count($r['result_uris'])) { + $this->addError('No result bindings specified.'); + } + /* dataset */ + while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { + $r['dataset'][] = $sub_r; + } + /* where */ + if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { + $r['pattern'] = $sub_r; + } + /* solution modifier */ + if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + /* all vars */ + if ($all_vars) { + foreach ($this->r['vars'] as $var) { + $r['result_vars'][] = array('var' => $var, 'aggregate' => 0, 'alias' => ''); + } + } + return array($r, $sub_v); + } + return array(0, $v); + } + + /* 8.. */ + + function xAskQuery($v) { + if ($sub_r = $this->x('ASK\s+', $v)) { + $r = array( + 'type' => 'ask', + 'dataset' => array(), + ); + $sub_v = $sub_r[1]; + /* dataset */ + while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { + $r['dataset'][] = $sub_r; + } + /* where */ + if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { + $r['pattern'] = $sub_r; + return array($r, $sub_v); + } + else { + $this->addError('Missing or invalid WHERE clause.'); + } + } + return array(0, $v); + } + + /* 9, 10, 11, 12 */ + + function xDatasetClause($v) { + if ($r = $this->x('FROM(\s+NAMED)?\s+', $v)) { + $named = $r[1] ? 1 : 0; + if ((list($r, $sub_v) = $this->xIRIref($r[2])) && $r) { + return array(array('graph' => $r, 'named' => $named), $sub_v); + } + } + return array(0, $v); + } + + /* 13 */ + + function xWhereClause($v) { + if ($r = $this->x('(WHERE)?', $v)) { + $v = $r[2]; + } + if ((list($r, $v) = $this->xGroupGraphPattern($v)) && $r) { + return array($r, $v); + } + return array(0, $v); + } + + /* 14, 15 */ + + function xSolutionModifier($v) { + $r = array(); + if ((list($sub_r, $sub_v) = $this->xOrderClause($v)) && $sub_r) { + $r['order_infos'] = $sub_r; + } + while ((list($sub_r, $sub_v) = $this->xLimitOrOffsetClause($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + return ($v == $sub_v) ? array(0, $v) : array($r, $sub_v); + } + + /* 18, 19 */ + + function xLimitOrOffsetClause($v) { + if ($sub_r = $this->x('(LIMIT|OFFSET)', $v)) { + $key = strtolower($sub_r[1]); + $sub_v = $sub_r[2]; + if ((list($sub_r, $sub_v) = $this->xINTEGER($sub_v)) && ($sub_r !== false)) { + return array(array($key =>$sub_r), $sub_v); + } + if ((list($sub_r, $sub_v) = $this->xPlaceholder($sub_v)) && ($sub_r !== false)) { + return array(array($key =>$sub_r), $sub_v); + } + } + return array(0, $v); + } + + /* 16 */ + + function xOrderClause($v) { + if ($sub_r = $this->x('ORDER BY\s+', $v)) { + $sub_v = $sub_r[1]; + $r = array(); + while ((list($sub_r, $sub_v) = $this->xOrderCondition($sub_v)) && $sub_r) { + $r[] = $sub_r; + } + if (count($r)) { + return array($r, $sub_v); + } + else { + $this->addError('No order conditions specified.'); + } + } + return array(0, $v); + } + + /* 17, 27 */ + + function xOrderCondition($v) { + if ($sub_r = $this->x('(ASC|DESC)', $v)) { + $dir = strtolower($sub_r[1]); + $sub_v = $sub_r[2]; + if ((list($sub_r, $sub_v) = $this->xBrackettedExpression($sub_v)) && $sub_r) { + $sub_r['direction'] = $dir; + return array($sub_r, $sub_v); + } + } + elseif ((list($sub_r, $sub_v) = $this->xVar($v)) && $sub_r) { + $sub_r['direction'] = 'asc'; + return array($sub_r, $sub_v); + } + elseif ((list($sub_r, $sub_v) = $this->xBrackettedExpression($v)) && $sub_r) { + return array($sub_r, $sub_v); + } + elseif ((list($sub_r, $sub_v) = $this->xBuiltInCall($v)) && $sub_r) { + $sub_r['direction'] = 'asc'; + return array($sub_r, $sub_v); + } + elseif ((list($sub_r, $sub_v) = $this->xFunctionCall($v)) && $sub_r) { + $sub_r['direction'] = 'asc'; + return array($sub_r, $sub_v); + } + return array(0, $v); + } + + /* 20 */ + + function xGroupGraphPattern($v) { + $pattern_id = substr(md5(uniqid(rand())), 0, 4); + if ($sub_r = $this->x('\{', $v)) { + $r = array('type' => 'group', 'patterns' => array()); + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xTriplesBlock($sub_v)) && $sub_r) { + $this->indexBnodes($sub_r, $pattern_id); + $r['patterns'][] = array('type' => 'triples', 'patterns' => $sub_r); + } + do { + $proceed = 0; + if ((list($sub_r, $sub_v) = $this->xGraphPatternNotTriples($sub_v)) && $sub_r) { + $r['patterns'][] = $sub_r; + $pattern_id = substr(md5(uniqid(rand())), 0, 4); + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xFilter($sub_v)) && $sub_r) { + $r['patterns'][] = array('type' => 'filter', 'constraint' => $sub_r); + $proceed = 1; + } + if ($sub_r = $this->x('\.', $sub_v)) { + $sub_v = $sub_r[1]; + } + if ((list($sub_r, $sub_v) = $this->xTriplesBlock($sub_v)) && $sub_r) { + $this->indexBnodes($sub_r, $pattern_id); + $r['patterns'][] = array('type' => 'triples', 'patterns' => $sub_r); + $proceed = 1; + } + if ((list($sub_r, $sub_v) = $this->xPlaceholder($sub_v)) && $sub_r) { + $r['patterns'][] = $sub_r; + $proceed = 1; + } + } while ($proceed); + if ($sub_r = $this->x('\}', $sub_v)) { + $sub_v = $sub_r[1]; + return array($r, $sub_v); + } + $rest = preg_replace('/[\x0a|\x0d]/i', ' ', substr($sub_v, 0, 30)); + $this->addError('Incomplete or invalid Group Graph pattern. Could not handle "' . $rest . '"'); + } + return array(0, $v); + } + + function indexBnodes($triples, $pattern_id) { + $index_id = count($this->bnode_pattern_index['patterns']); + $index_id = $pattern_id; + $this->bnode_pattern_index['patterns'][] = $triples; + foreach ($triples as $t) { + foreach (array('s', 'p', 'o') as $term) { + if ($t[$term . '_type'] == 'bnode') { + $val = $t[$term]; + if (isset($this->bnode_pattern_index['bnodes'][$val]) && ($this->bnode_pattern_index['bnodes'][$val] != $index_id)) { + $this->addError('Re-used bnode label "' .$val. '" across graph patterns'); + } + else { + $this->bnode_pattern_index['bnodes'][$val] = $index_id; + } + } + } + } + } + + /* 22.., 25.. */ + + function xGraphPatternNotTriples($v) { + if ((list($sub_r, $sub_v) = $this->xOptionalGraphPattern($v)) && $sub_r) { + return array($sub_r, $sub_v); + } + if ((list($sub_r, $sub_v) = $this->xGraphGraphPattern($v)) && $sub_r) { + return array($sub_r, $sub_v); + } + $r = array('type' => 'union', 'patterns' => array()); + $sub_v = $v; + do { + $proceed = 0; + if ((list($sub_r, $sub_v) = $this->xGroupGraphPattern($sub_v)) && $sub_r) { + $r['patterns'][] = $sub_r; + if ($sub_r = $this->x('UNION', $sub_v)) { + $sub_v = $sub_r[1]; + $proceed = 1; + } + } + } while ($proceed); + $pc = count($r['patterns']); + if ($pc == 1) { + return array($r['patterns'][0], $sub_v); + } + elseif ($pc > 1) { + return array($r, $sub_v); + } + return array(0, $v); + } + + /* 23 */ + + function xOptionalGraphPattern($v) { + if ($sub_r = $this->x('OPTIONAL', $v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xGroupGraphPattern($sub_v)) && $sub_r) { + return array(array('type' => 'optional', 'patterns' => $sub_r['patterns']), $sub_v); + } + $this->addError('Missing or invalid Group Graph Pattern after OPTIONAL'); + } + return array(0, $v); + } + + /* 24.. */ + + function xGraphGraphPattern($v) { + if ($sub_r = $this->x('GRAPH', $v)) { + $sub_v = $sub_r[1]; + $r = array('type' => 'graph', 'var' => '', 'uri' => '', 'patterns' => array()); + if ((list($sub_r, $sub_v) = $this->xVar($sub_v)) && $sub_r) { + $r['var'] = $sub_r; + } + elseif ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { + $r['uri'] = $sub_r; + } + if ($r['var'] || $r['uri']) { + if ((list($sub_r, $sub_v) = $this->xGroupGraphPattern($sub_v)) && $sub_r) { + $r['patterns'][] = $sub_r; + return array($r, $sub_v); + } + $this->addError('Missing or invalid Graph Pattern'); + } + } + return array(0, $v); + } + + /* 26.., 27.. */ + + function xFilter($v) { + if ($r = $this->x('FILTER', $v)) { + $sub_v = $r[1]; + if ((list($r, $sub_v) = $this->xBrackettedExpression($sub_v)) && $r) { + return array($r, $sub_v); + } + if ((list($r, $sub_v) = $this->xBuiltInCall($sub_v)) && $r) { + return array($r, $sub_v); + } + if ((list($r, $sub_v) = $this->xFunctionCall($sub_v)) && $r) { + return array($r, $sub_v); + } + $this->addError('Incomplete FILTER'); + } + return array(0, $v); + } + + /* 28.. */ + + function xFunctionCall($v) { + if ((list($r, $sub_v) = $this->xIRIref($v)) && $r) { + if ((list($sub_r, $sub_v) = $this->xArgList($sub_v)) && $sub_r) { + return array(array('type' => 'function_call', 'uri' => $r, 'args' => $sub_r), $sub_v); + } + } + return array(0, $v); + } + + /* 29 */ + + function xArgList($v) { + $r = array(); + $sub_v = $v; + $closed = 0; + if ($sub_r = $this->x('\(', $sub_v)) { + $sub_v = $sub_r[1]; + do { + $proceed = 0; + if ((list($sub_r, $sub_v) = $this->xExpression($sub_v)) && $sub_r) { + $r[] = $sub_r; + if ($sub_r = $this->x('\,', $sub_v)) { + $sub_v = $sub_r[1]; + $proceed = 1; + } + } + if ($sub_r = $this->x('\)', $sub_v)) { + $sub_v = $sub_r[1]; + $closed = 1; + $proceed = 0; + } + } while ($proceed); + } + return $closed ? array($r, $sub_v) : array(0, $v); + } + + /* 30, 31 */ + + function xConstructTemplate($v) { + if ($sub_r = $this->x('\{', $v)) { + $r = array(); + if ((list($sub_r, $sub_v) = $this->xTriplesBlock($sub_r[1])) && is_array($sub_r)) { + $r = $sub_r; + } + if ($sub_r = $this->x('\}', $sub_v)) { + return array($r, $sub_r[1]); + } + } + return array(0, $v); + } + + /* 46, 47 */ + + function xExpression($v) { + if ((list($sub_r, $sub_v) = $this->xConditionalAndExpression($v)) && $sub_r) { + $r = array('type' => 'expression', 'sub_type' => 'or', 'patterns' => array($sub_r)); + do { + $proceed = 0; + if ($sub_r = $this->x('\|\|', $sub_v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xConditionalAndExpression($sub_v)) && $sub_r) { + $r['patterns'][] = $sub_r; + $proceed = 1; + } + } + } while ($proceed); + return count($r['patterns']) == 1 ? array($r['patterns'][0], $sub_v) : array($r, $sub_v); + } + return array(0, $v); + } + + /* 48.., 49.. */ + + function xConditionalAndExpression($v) { + if ((list($sub_r, $sub_v) = $this->xRelationalExpression($v)) && $sub_r) { + $r = array('type' => 'expression', 'sub_type' => 'and', 'patterns' => array($sub_r)); + do { + $proceed = 0; + if ($sub_r = $this->x('\&\&', $sub_v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xRelationalExpression($sub_v)) && $sub_r) { + $r['patterns'][] = $sub_r; + $proceed = 1; + } + } + } while ($proceed); + return count($r['patterns']) == 1 ? array($r['patterns'][0], $sub_v) : array($r, $sub_v); + } + return array(0, $v); + } + + /* 50, 51 */ + + function xRelationalExpression($v) { + if ((list($sub_r, $sub_v) = $this->xAdditiveExpression($v)) && $sub_r) { + $r = array('type' => 'expression', 'sub_type' => 'relational', 'patterns' => array($sub_r)); + do { + $proceed = 0; + /* don't mistake '<' + uriref with '<'-operator ("longest token" rule) */ + if ((list($sub_r, $sub_v) = $this->xIRI_REF($sub_v)) && $sub_r) { + $this->addError('Expected operator, found IRIref: "'.$sub_r.'".'); + } + if ($sub_r = $this->x('(\!\=|\=\=|\=|\<\=|\>\=|\<|\>)', $sub_v)) { + $op = $sub_r[1]; + $sub_v = $sub_r[2]; + $r['operator'] = $op; + if ((list($sub_r, $sub_v) = $this->xAdditiveExpression($sub_v)) && $sub_r) { + //$sub_r['operator'] = $op; + $r['patterns'][] = $sub_r; + $proceed = 1; + } + } + } while ($proceed); + return count($r['patterns']) == 1 ? array($r['patterns'][0], $sub_v) : array($r, $sub_v); + } + return array(0, $v); + } + + /* 52 */ + + function xAdditiveExpression($v) { + if ((list($sub_r, $sub_v) = $this->xMultiplicativeExpression($v)) && $sub_r) { + $r = array('type' => 'expression', 'sub_type' => 'additive', 'patterns' => array($sub_r)); + do { + $proceed = 0; + if ($sub_r = $this->x('(\+|\-)', $sub_v)) { + $op = $sub_r[1]; + $sub_v = $sub_r[2]; + if ((list($sub_r, $sub_v) = $this->xMultiplicativeExpression($sub_v)) && $sub_r) { + $sub_r['operator'] = $op; + $r['patterns'][] = $sub_r; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xNumericLiteral($sub_v)) && $sub_r) { + $r['patterns'][] = array('type' => 'numeric', 'operator' => $op, 'value' => $sub_r); + $proceed = 1; + } + } + } while ($proceed); + //return array($r, $sub_v); + return count($r['patterns']) == 1 ? array($r['patterns'][0], $sub_v) : array($r, $sub_v); + } + return array(0, $v); + } + + /* 53 */ + + function xMultiplicativeExpression($v) { + if ((list($sub_r, $sub_v) = $this->xUnaryExpression($v)) && $sub_r) { + $r = array('type' => 'expression', 'sub_type' => 'multiplicative', 'patterns' => array($sub_r)); + do { + $proceed = 0; + if ($sub_r = $this->x('(\*|\/)', $sub_v)) { + $op = $sub_r[1]; + $sub_v = $sub_r[2]; + if ((list($sub_r, $sub_v) = $this->xUnaryExpression($sub_v)) && $sub_r) { + $sub_r['operator'] = $op; + $r['patterns'][] = $sub_r; + $proceed = 1; + } + } + } while ($proceed); + return count($r['patterns']) == 1 ? array($r['patterns'][0], $sub_v) : array($r, $sub_v); + } + return array(0, $v); + } + + /* 54 */ + + function xUnaryExpression($v) { + $sub_v = $v; + $op = ''; + if ($sub_r = $this->x('(\!|\+|\-)', $sub_v)) { + $op = $sub_r[1]; + $sub_v = $sub_r[2]; + } + if ((list($sub_r, $sub_v) = $this->xPrimaryExpression($sub_v)) && $sub_r) { + if (!is_array($sub_r)) { + $sub_r = array('type' => 'unary', 'expression' => $sub_r); + } + elseif ($sub_op = $this->v1('operator', '', $sub_r)) { + $ops = array('!!' => '', '++' => '+', '--' => '+', '+-' => '-', '-+' => '-'); + $op = isset($ops[$op . $sub_op]) ? $ops[$op . $sub_op] : $op . $sub_op; + } + $sub_r['operator'] = $op; + return array($sub_r, $sub_v); + } + return array(0, $v); + } + + /* 55 */ + + function xPrimaryExpression($v) { + foreach (array('BrackettedExpression', 'BuiltInCall', 'IRIrefOrFunction', 'RDFLiteral', 'NumericLiteral', 'BooleanLiteral', 'Var', 'Placeholder') as $type) { + $m = 'x' . $type; + if ((list($sub_r, $sub_v) = $this->$m($v)) && $sub_r) { + return array($sub_r, $sub_v); + } + } + return array(0, $v); + } + + /* 56 */ + + function xBrackettedExpression($v) { + if ($r = $this->x('\(', $v)) { + if ((list($r, $sub_v) = $this->xExpression($r[1])) && $r) { + if ($sub_r = $this->x('\)', $sub_v)) { + return array($r, $sub_r[1]); + } + } + } + return array(0, $v); + } + + /* 57.., 58.. */ + + function xBuiltInCall($v) { + if ($sub_r = $this->x('(str|lang|langmatches|datatype|bound|sameterm|isiri|isuri|isblank|isliteral|regex)\s*\(', $v)) { + $r = array('type' => 'built_in_call', 'call' => strtolower($sub_r[1])); + if ((list($sub_r, $sub_v) = $this->xArgList('(' . $sub_r[2])) && is_array($sub_r)) { + $r['args'] = $sub_r; + return array($r, $sub_v); + } + } + return array(0, $v); + } + + /* 59.. */ + + function xIRIrefOrFunction($v) { + if ((list($r, $v) = $this->xIRIref($v)) && $r) { + if ((list($sub_r, $sub_v) = $this->xArgList($v)) && is_array($sub_r)) { + return array(array('type' => 'function', 'uri' => $r, 'args' => $sub_r), $sub_v); + } + return array(array('type' => 'uri', 'uri' => $r), $sub_v); + } + } + + /* 70.. @@sync with TurtleParser */ + + function xIRI_REF($v) { + if (($r = $this->x('\<(\$\{[^\>]*\})\>', $v)) && ($sub_r = $this->xPlaceholder($r[1]))) { + return array($r[1], $r[2]); + } + elseif ($r = $this->x('\<([^\<\>\s\"\|\^`]*)\>', $v)) { + return array($r[1] ? $r[1] : true, $r[2]); + } + /* allow reserved chars in obvious IRIs */ + elseif ($r = $this->x('\<(https?\:[^\s][^\<\>]*)\>', $v)) { + return array($r[1] ? $r[1] : true, $r[2]); + } + return array(0, $v); + } + +} diff --git a/arc2-2.2.4/parsers/ARC2_SPARQLPlusParser.php b/arc2-2.2.4/parsers/ARC2_SPARQLPlusParser.php new file mode 100755 index 0000000..e804802 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_SPARQLPlusParser.php @@ -0,0 +1,210 @@ +xPrologue($v); + foreach (array('Select', 'Construct', 'Describe', 'Ask', 'Insert', 'Delete', 'Load') as $type) { + $m = 'x' . $type . 'Query'; + if ((list($r, $v) = $this->$m($v)) && $r) { + return array($r, $v); + } + } + return array(0, $v); + } + + /* +3 */ + + function xResultVar($v) { + $aggregate = ''; + /* aggregate */ + if ($sub_r = $this->x('\(?(AVG|COUNT|MAX|MIN|SUM)\s*\(\s*([^\)]+)\)\s+AS\s+([^\s\)]+)\)?', $v)) { + $aggregate = $sub_r[1]; + $result_var = $sub_r[3]; + $v = $sub_r[2] . $sub_r[4]; + } + if ($sub_r && (list($sub_r, $sub_v) = $this->xVar($result_var)) && $sub_r) { + $result_var = $sub_r['value']; + } + /* * or var */ + if ((list($sub_r, $sub_v) = $this->x('\*', $v)) && $sub_r) { + return array(array('var' => $sub_r['value'], 'aggregate' => $aggregate, 'alias' => $aggregate ? $result_var : ''), $sub_v); + } + if ((list($sub_r, $sub_v) = $this->xVar($v)) && $sub_r) { + return array(array('var' => $sub_r['value'], 'aggregate' => $aggregate, 'alias' => $aggregate ? $result_var : ''), $sub_v); + } + return array(0, $v); + } + + /* +4 */ + + function xLoadQuery($v) { + if ($sub_r = $this->x('LOAD\s+', $v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { + $r = array('type' => 'load', 'url' => $sub_r, 'target_graph' => ''); + if ($sub_r = $this->x('INTO\s+', $sub_v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { + $r['target_graph'] = $sub_r; + } + } + return array($r, $sub_v); + } + } + return array(0, $v); + } + + /* +5 */ + + function xInsertQuery($v) { + if ($sub_r = $this->x('INSERT\s+', $v)) { + $r = array( + 'type' => 'insert', + 'dataset' => array(), + ); + $sub_v = $sub_r[1]; + /* target */ + if ($sub_r = $this->x('INTO\s+', $sub_v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { + $r['target_graph'] = $sub_r; + /* CONSTRUCT keyword, optional */ + if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { + $sub_v = $sub_r[1]; + } + /* construct template */ + if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { + $r['construct_triples'] = $sub_r; + } + else { + $this->addError('Construct Template not found'); + return array(0, $v); + } + /* dataset */ + while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { + $r['dataset'][] = $sub_r; + } + /* where */ + if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { + $r['pattern'] = $sub_r; + } + /* solution modifier */ + if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + return array($r, $sub_v); + } + } + } + return array(0, $v); + } + + /* +6 */ + + function xDeleteQuery($v) { + if ($sub_r = $this->x('DELETE\s+', $v)) { + $r = array( + 'type' => 'delete', + 'target_graphs' => array() + ); + $sub_v = $sub_r[1]; + /* target */ + do { + $proceed = false; + if ($sub_r = $this->x('FROM\s+', $sub_v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { + $r['target_graphs'][] = $sub_r; + $proceed = 1; + } + } + } while ($proceed); + /* CONSTRUCT keyword, optional */ + if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { + $sub_v = $sub_r[1]; + } + /* construct template */ + if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { + $r['construct_triples'] = $sub_r; + /* dataset */ + while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { + $r['dataset'][] = $sub_r; + } + /* where */ + if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { + $r['pattern'] = $sub_r; + } + /* solution modifier */ + if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + } + return array($r, $sub_v); + } + return array(0, $v); + } + + /* +7 */ + + function xSolutionModifier($v) { + $r = array(); + if ((list($sub_r, $sub_v) = $this->xGroupClause($v)) && $sub_r) { + $r['group_infos'] = $sub_r; + } + if ((list($sub_r, $sub_v) = $this->xOrderClause($sub_v)) && $sub_r) { + $r['order_infos'] = $sub_r; + } + while ((list($sub_r, $sub_v) = $this->xLimitOrOffsetClause($sub_v)) && $sub_r) { + $r = array_merge($r, $sub_r); + } + return ($v == $sub_v) ? array(0, $v) : array($r, $sub_v); + } + + /* +8 */ + + function xGroupClause($v) { + if ($sub_r = $this->x('GROUP BY\s+', $v)) { + $sub_v = $sub_r[1]; + $r = array(); + do { + $proceed = 0; + if ((list($sub_r, $sub_v) = $this->xVar($sub_v)) && $sub_r) { + $r[] = $sub_r; + $proceed = 1; + if ($sub_r = $this->x('\,', $sub_v)) { + $sub_v = $sub_r[1]; + } + } + } while ($proceed); + if (count($r)) { + return array($r, $sub_v); + } + else { + $this->addError('No columns specified in GROUP BY clause.'); + } + } + return array(0, $v); + } + +} diff --git a/arc2-2.2.4/parsers/ARC2_SPARQLXMLResultParser.php b/arc2-2.2.4/parsers/ARC2_SPARQLXMLResultParser.php new file mode 100755 index 0000000..28d0049 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_SPARQLXMLResultParser.php @@ -0,0 +1,112 @@ +srx = 'http://www.w3.org/2005/sparql-results#'; + $this->nsp[$this->srx] = 'srx'; + $this->allowCDataNodes = 0; + } + + /* */ + + function done() { + } + + /* */ + + function getVariables() { + $r = array(); + foreach ($this->nodes as $node) { + if ($node['tag'] == $this->srx . 'variable') { + $r[] = $node['a']['name']; + } + } + return $r; + } + + function getRows() { + $r = array(); + $index = $this->getNodeIndex(); + foreach ($this->nodes as $node) { + if ($node['tag'] == $this->srx . 'result') { + $row = array(); + $row_id = $node['id']; + $bindings = isset($index[$row_id])? $index[$row_id] : array(); + foreach ($bindings as $binding) { + $row = array_merge($row, $this->getBinding($binding)); + } + if ($row) { + $r[] = $row; + } + } + } + return $r; + } + + function getBinding($node) { + $r = array(); + $index = $this->getNodeIndex(); + $var = $node['a']['name']; + $term = $index[$node['id']][0]; + $r[$var . ' type'] = preg_replace('/^uri$/', 'uri', substr($term['tag'], strlen($this->srx))); + $r[$var] = ($r[$var . ' type'] == 'bnode') ? '_:' . $term['cdata'] : $term['cdata']; + if (isset($term['a']['datatype'])) { + $r[$var . ' datatype'] = $term['a']['datatype']; + } + elseif (isset($term['a'][$this->xml . 'lang'])) { + $r[$var . ' lang'] = $term['a'][$this->xml . 'lang']; + } + return $r; + } + + function getBooleanInsertedDeleted() { + foreach ($this->nodes as $node) { + if ($node['tag'] == $this->srx . 'boolean') { + return ($node['cdata'] == 'true') ? array('boolean' => true) : array('boolean' => false); + } + elseif ($node['tag'] == $this->srx . 'inserted') { + return array('inserted' => $node['cdata']); + } + elseif ($node['tag'] == $this->srx . 'deleted') { + return array('deleted' => $node['cdata']); + } + elseif ($node['tag'] == $this->srx . 'results') { + return ''; + } + } + return ''; + } + + /* */ + + function getStructure() { + $r = array('variables' => $this->getVariables(), 'rows' => $this->getRows()); + /* boolean|inserted|deleted */ + if ($sub_r = $this->getBooleanInsertedDeleted()) { + foreach ($sub_r as $k => $v) { + $r[$k] = $v; + } + } + return $r; + } + + /* */ + + +} diff --git a/arc2-2.2.4/parsers/ARC2_SPOGParser.php b/arc2-2.2.4/parsers/ARC2_SPOGParser.php new file mode 100755 index 0000000..71c41e6 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_SPOGParser.php @@ -0,0 +1,188 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFParser'); + +class ARC2_SPOGParser extends ARC2_RDFParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* reader */ + parent::__init(); + $this->encoding = $this->v('encoding', false, $this->a); + $this->xml = 'http://www.w3.org/XML/1998/namespace'; + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->nsp = array($this->xml => 'xml', $this->rdf => 'rdf'); + $this->target_encoding = ''; + } + + /* */ + + function parse($path, $data = '', $iso_fallback = false) { + $this->state = 0; + /* reader */ + if (!$this->v('reader')) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->setAcceptHeader('Accept: sparql-results+xml; q=0.9, */*; q=0.1'); + $this->reader->activate($path, $data); + $this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base; + /* xml parser */ + $this->initXMLParser(); + /* parse */ + $first = true; + while ($d = $this->reader->readStream()) { + if ($iso_fallback && $first) { + $d = '' . "\n" . preg_replace('/^\<\?xml [^\>]+\?\>\s*/s', '', $d); + $first = false; + } + if (!xml_parse($this->xml_parser, $d, false)) { + $error_str = xml_error_string(xml_get_error_code($this->xml_parser)); + $line = xml_get_current_line_number($this->xml_parser); + $this->tmp_error = 'XML error: "' . $error_str . '" at line ' . $line . ' (parsing as ' . $this->getEncoding() . ')'; + $this->tmp_error .= $d . urlencode($d); + if (0 && !$iso_fallback && preg_match("/Invalid character/i", $error_str)) { + xml_parser_free($this->xml_parser); + unset($this->xml_parser); + $this->reader->closeStream(); + $this->__init(); + $this->encoding = 'ISO-8859-1'; + unset($this->xml_parser); + unset($this->reader); + return $this->parse($path, $data, true); + } + else { + return $this->addError($this->tmp_error); + } + } + } + $this->target_encoding = xml_parser_get_option($this->xml_parser, XML_OPTION_TARGET_ENCODING); + xml_parser_free($this->xml_parser); + $this->reader->closeStream(); + unset($this->reader); + return $this->done(); + } + + /* */ + + function initXMLParser() { + if (!isset($this->xml_parser)) { + $enc = preg_match('/^(utf\-8|iso\-8859\-1|us\-ascii)$/i', $this->getEncoding(), $m) ? $m[1] : 'UTF-8'; + $parser = xml_parser_create($enc); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, 'open', 'close'); + xml_set_character_data_handler($parser, 'cdata'); + xml_set_start_namespace_decl_handler($parser, 'nsDecl'); + xml_set_object($parser, $this); + $this->xml_parser = $parser; + } + } + + /* */ + + function getEncoding($src = 'config') { + if ($src == 'parser') { + return $this->target_encoding; + } + elseif (($src == 'config') && $this->encoding) { + return $this->encoding; + } + return $this->reader->getEncoding(); + return 'UTF-8'; + } + + /* */ + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + function addT($s = '', $p = '', $o = '', $s_type = '', $o_type = '', $o_dt = '', $o_lang = '', $g = '') { + if (!($s && $p && $o)) return 0; + //echo "-----\nadding $s / $p / $o\n-----\n"; + $t = array('s' => $s, 'p' => $p, 'o' => $o, 's_type' => $s_type, 'o_type' => $o_type, 'o_datatype' => $o_dt, 'o_lang' => $o_lang, 'g' => $g); + if ($this->skip_dupes) { + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + /* */ + + function open($p, $t, $a) { + $this->state = $t; + if ($t == 'result') { + $this->t = array(); + } + elseif ($t == 'binding') { + $this->binding = $a['name']; + $this->t[$this->binding] = ''; + } + elseif ($t == 'literal') { + $this->t[$this->binding . '_dt'] = $this->v('datatype', '', $a); + $this->t[$this->binding . '_lang'] = $this->v('xml:lang', '', $a); + $this->t[$this->binding . '_type'] = 'literal'; + } + elseif ($t == 'uri') { + $this->t[$this->binding . '_type'] = 'uri'; + } + elseif ($t == 'bnode') { + $this->t[$this->binding . '_type'] = 'bnode'; + $this->t[$this->binding] = '_:'; + } + } + + function close($p, $t) { + $this->prev_state = $this->state; + $this->state = ''; + if ($t == 'result') { + $this->addT( + $this->v('s', '', $this->t), + $this->v('p', '', $this->t), + $this->v('o', '', $this->t), + $this->v('s_type', '', $this->t), + $this->v('o_type', '', $this->t), + $this->v('o_dt', '', $this->t), + $this->v('o_lang', '', $this->t), + $this->v('g', '', $this->t) + ); + } + } + + function cData($p, $d) { + if (in_array($this->state, array('uri', 'bnode', 'literal'))) { + $this->t[$this->binding] .= $d; + } + } + + function nsDecl($p, $prf, $uri) { + $this->nsp[$uri] = isset($this->nsp[$uri]) ? $this->nsp[$uri] : $prf; + } + + /* */ + +} diff --git a/arc2-2.2.4/parsers/ARC2_SemHTMLParser.php b/arc2-2.2.4/parsers/ARC2_SemHTMLParser.php new file mode 100755 index 0000000..28738c1 --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_SemHTMLParser.php @@ -0,0 +1,339 @@ +default_sem_html_formats = 'dc openid erdf rdfa posh-rdf microformats'; + $this->triples = array(); + $this->target_encoding = ''; + $this->t_count = 0; + $this->added_triples = array(); + $this->skip_dupes = false; + $this->bnode_prefix = $this->v('bnode_prefix', 'arc'.substr(md5(uniqid(rand())), 0, 4).'b', $this->a); + $this->bnode_id = 0; + $this->auto_extract = $this->v('auto_extract', 1, $this->a); + $this->extracted_formats = array(); + $this->cache = array(); + $this->detected_formats = array(); + $this->keep_cdata_ws = $this->v('keep_cdata_whitespace', 0, $this->a); + } + + /* */ + + function x($re, $v, $options = 'si', $keep_ws = 0) { + list($ws, $v) = preg_match('/^(\s*)(.*)$/s', $v, $m) ? array($m[1], $m[2]) : array('', $v); + if (preg_match("/^" . $re . "(.*)$/" . $options, $v, $m)) { + if ($keep_ws) $m[1] = $ws . $m[1]; + return $m; + } + return false; + } + + /* */ + + function setReader(&$reader) { + $this->reader = $reader; + } + + function createBnodeID(){ + $this->bnode_id++; + return '_:' . $this->bnode_prefix . $this->bnode_id; + } + + function addT($t) { + if (function_exists('html_entity_decode')) { + $t['o'] = html_entity_decode($t['o']); + } + if ($this->skip_dupes) { + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + function getSimpleIndex($flatten_objects = 1, $vals = '') { + return ARC2::getSimpleIndex($this->getTriples(), $flatten_objects, $vals); + } + + /* */ + + function parse($path, $data = '', $iso_fallback = 'ignore') { + $this->nodes = array(); + $this->node_count = 0; + $this->level = 0; + /* reader */ + if (!$this->v('reader')) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->setAcceptHeader('Accept: text/html, application/xhtml, */*; q=0.9'); + $this->reader->activate($path, $data); + $this->target_encoding = $this->reader->getEncoding(false); + $this->x_base = isset($this->a['base']) && $this->a['base'] ? $this->a['base'] : $this->reader->base; + $this->base = $this->x_base; + $this->doc_url = $this->reader->base; + /* parse */ + $rest = ''; + $this->cur_tag = ''; + while ($d = $this->reader->readStream(1)) { + $rest = $this->processData($rest . $d); + } + $this->reader->closeStream(); + unset($this->reader); + return $this->done(); + } + + /* */ + + function getEncoding($src = 'ignore') { + return $this->target_encoding; + } + + /* */ + + function done() { + if ($this->auto_extract) { + $this->extractRDF(); + } + } + + /* */ + + function processData($v) { + $sub_v = $v; + do { + $proceed = 1; + if ((list($sub_r, $sub_v) = $this->xComment($sub_v)) && $sub_r) { + $this->open(0, 'comment', array('value' => $sub_r)); + $this->close(0, 'comment'); + continue; + } + if ((list($sub_r, $sub_v) = $this->xDoctype($sub_v)) && $sub_r) { + $this->open(0, 'doctype', array('value' => $sub_r)); + $this->close(0, 'doctype'); + /* RDFa detection */ + if (preg_match('/rdfa /i', $sub_r)) $this->detected_formats['rdfa'] = 1; + continue; + } + if ($this->level && ((list($sub_r, $sub_v) = $this->xWS($sub_v)) && $sub_r)) { + $this->cData(0, $sub_r); + } + elseif ((list($sub_r, $sub_v) = $this->xOpen($sub_v)) && $sub_r) { + $this->open(0, $sub_r['tag'], $sub_r['a']); + $this->cur_tag = $sub_r['tag']; + if ($sub_r['empty']) { + $this->close(0, $sub_r['tag'], 1); + $this->cur_tag = ''; + } + /* eRDF detection */ + if (!isset($this->detected_formats['erdf']) && isset($sub_r['a']['profile m']) && in_array('http://purl.org/NET/erdf/profile', $sub_r['a']['profile m'])) $this->detected_formats['erdf'] = 1; + /* poshRDF detection */ + if (!isset($this->detected_formats['posh-rdf']) && isset($sub_r['a']['class m']) && in_array('rdf-p', $sub_r['a']['class m'])) $this->detected_formats['posh-rdf'] = 1; + /* RDFa detection */ + if (!isset($this->detected_formats['rdfa']) && ($this->cur_tag == 'html') && isset($sub_r['a']['version m']) && in_array('XHTML+RDFa', $sub_r['a']['version m'])) $this->detected_formats['rdfa'] = 1; + if (!isset($this->detected_formats['rdfa']) && isset($sub_r['a']['xmlns']) && $sub_r['a']['xmlns'] && $this->isRDFNSDecl($sub_r['a']['xmlns'])) $this->detected_formats['rdfa'] = 1; + if (!isset($this->detected_formats['rdfa']) && array_intersect(array('about', 'typeof', 'property'), array_keys($sub_r['a']))) $this->detected_formats['rdfa'] = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xClose($sub_v)) && $sub_r) { + if (preg_match('/^(area|base|br|col|frame|hr|input|img|link|xmeta|param)$/', $sub_r['tag'])) { + /* already implicitly closed */ + } + else { + $this->close(0, $sub_r['tag']); + $this->cur_tag = ''; + } + } + elseif ((list($sub_r, $sub_v) = $this->xCData($sub_v)) && $sub_r) { + $this->cData(0, $sub_r); + } + else { + $proceed = 0; + } + } while ($proceed); + return $sub_v; + } + + /* */ + + function isRDFNSDecl($ns) { + foreach ($ns as $k => $v) { + if ($k) return 1; + } + return 0; + } + + /* */ + + function xComment($v) { + if ($r = $this->x('\<\!\-\-', $v)) { + if ($sub_r = $this->x('(.*)\-\-\>', $r[1], 'Us')) { + return array($sub_r[1], $sub_r[2]); + } + } + return array(0, $v); + } + + function xDoctype($v) { + if ($r = $this->x('\<\!DOCTYPE', $v)) { + if ($sub_r = $this->x('([^\>]+)\>', $r[1])) { + return array($sub_r[1], $sub_r[2]); + } + } + return array(0, $v); + } + + function xWS($v) { + if ($r = ARC2::x('(\s+)', $v)) { + return array($r[1], $r[2]); + } + return array(0, $v); + } + + /* */ + + function xOpen($v) { + if ($r = $this->x('\<([^\s\/\>]+)([^\>]*)\>', $v)) { + list($sub_r, $sub_v) = $this->xAttributes($r[2]); + return array(array('tag' => strtolower($r[1]), 'a' => $sub_r, 'empty' => $this->isEmpty($r[1], $r[2])), $r[3]); + } + return array(0, $v); + } + + /* */ + + function xAttributes($v) { + $r = array(); + while ((list($sub_r, $v) = $this->xAttribute($v)) && $sub_r) { + if ($sub_sub_r = $this->x('xmlns\:?(.*)', $sub_r['k'])) { + $this->nsDecl(0, $sub_sub_r[1], $sub_r['value']); + $r['xmlns'][$sub_sub_r[1]] = $sub_r['value']; + } + else { + $r[$sub_r['k']] = $sub_r['value']; + $r[$sub_r['k'] . ' m'] = $sub_r['values']; + } + } + return array($r, $v); + } + + /* */ + + function xAttribute($v) { + if ($r = $this->x('([^\s\=]+)\s*(\=)?\s*([\'\"]?)', $v)) { + if (!$r[2]) {/* no '=' */ + if ($r[1] == '/') { + return array(0, $r[4]); + } + return array(array('k' => $r[1], 'value' => 1, 'values' => array(1)), $r[4]); + } + if (!$r[3]) {/* no quots */ + if ($sub_r = $this->x('([^\s]+)', $r[4])) { + return array(array('k' => $r[1], 'value' => $sub_r[1], 'values' => array($sub_r[1])), $sub_r[2]); + } + return array(array('k' => $r[1], 'value' => '', 'values' => array()), $r[4]); + } + $val = ''; + $multi = 0; + $sub_v = $r[4]; + while ($sub_v && (!$sub_r = $this->x('(\x5c\\' .$r[3]. '|\\' .$r[3]. ')', $sub_v))) { + $val .= substr($sub_v, 0, 1); + $sub_v = substr($sub_v, 1); + } + $sub_v = $sub_v ? $sub_r[2] : $sub_v; + $vals = preg_split('/ /', $val); + return array(array('k' => $r[1], 'value' => $val, 'values' => $vals), $sub_v); + } + return array(0, $v); + } + + /* */ + + function isEmpty($t, $v) { + if (preg_match('/^(area|base|br|col|frame|hr|input|img|link|xmeta|param)$/', $t)) { + return 1; + } + if (preg_match('/\/$/', $v)) { + return 1; + } + return 0; + } + + /* */ + + function xClose($v) { + if ($r = $this->x('\<\/([^\s\>]+)\>', $v)) { + return array(array('tag' => strtolower($r[1])), $r[2]); + } + return array(0, $v); + } + + /* */ + + function xCData($v) { + if (preg_match('/(script|style)/i', $this->cur_tag)) { + if ($r = $this->x('(.+)(\<\/' . $this->cur_tag . '\>)', $v, 'Uis')) { + return array($r[1], $r[2] . $r[3]); + } + } + elseif ($r = $this->x('([^\<]+)', $v, 'si', $this->keep_cdata_ws)) { + return array($r[1], $r[2]); + } + return array(0, $v); + } + + /* */ + + function extractRDF($formats = '') { + $this->node_index = $this->getNodeIndex(); + $formats = !$formats ? $this->v('sem_html_formats', $this->default_sem_html_formats, $this->a) : $formats; + $formats = preg_split('/ /', $formats); + foreach ($formats as $format) { + if (!in_array($format, $this->extracted_formats)) { + $comp = $this->camelCase($format) . 'Extractor'; + if (ARC2::inc($comp)) { + $cls = 'ARC2_' . $comp; + $e = new $cls($this->a, $this); + $e->extractRDF(); + } + $this->extracted_formats[] = $format; + } + } + } + + function getNode($id) { + return isset($this->nodes[$id]) ? $this->nodes[$id] : 0; + } + + /* */ + +} \ No newline at end of file diff --git a/arc2-2.2.4/parsers/ARC2_TurtleParser.php b/arc2-2.2.4/parsers/ARC2_TurtleParser.php new file mode 100755 index 0000000..64d6e1a --- /dev/null +++ b/arc2-2.2.4/parsers/ARC2_TurtleParser.php @@ -0,0 +1,886 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFParser'); + +class ARC2_TurtleParser extends ARC2_RDFParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* reader */ + parent::__init(); + $this->state = 0; + $this->xml = 'http://www.w3.org/XML/1998/namespace'; + $this->rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $this->xsd = 'http://www.w3.org/2001/XMLSchema#'; + $this->nsp = array($this->xml => 'xml', $this->rdf => 'rdf', $this->xsd => 'xsd'); + $this->unparsed_code = ''; + $this->max_parsing_loops = $this->v('turtle_max_parsing_loops', 500, $this->a); + } + + /* */ + + function x($re, $v, $options = 'si') { + $v = preg_replace('/^[\xA0\xC2]+/', ' ', $v); + while (preg_match('/^\s*(\#[^\xd\xa]*)(.*)$/si', $v, $m)) {/* comment removal */ + $v = $m[2]; + } + return ARC2::x($re, $v, $options); + //$this->unparsed_code = ($sub_r && count($sub_r)) ? $sub_r[count($sub_r) - 1] : ''; + } + + function createBnodeID(){ + $this->bnode_id++; + return '_:' . $this->bnode_prefix . $this->bnode_id; + } + + /* */ + + function addT($t) { + if ($this->skip_dupes) { + $h = md5(serialize($t)); + if (!isset($this->added_triples[$h])) { + $this->triples[$this->t_count] = $t; + $this->t_count++; + $this->added_triples[$h] = true; + } + } + else { + $this->triples[$this->t_count] = $t; + $this->t_count++; + } + } + + /* */ + + function getTriples() { + return $this->v('triples', array()); + } + + function countTriples() { + return $this->t_count; + } + + /* */ + + function getUnparsedCode() { + return $this->v('unparsed_code', ''); + } + + /* */ + + function setDefaultPrefixes() { + $this->prefixes = array( + 'rdf:' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + 'rdfs:' => 'http://www.w3.org/2000/01/rdf-schema#', + 'owl:' => 'http://www.w3.org/2002/07/owl#', + 'xsd:' => 'http://www.w3.org/2001/XMLSchema#', + ); + if ($ns = $this->v('ns', array(), $this->a)) { + foreach ($ns as $p => $u) $this->prefixes[$p . ':'] = $u; + } + } + + + function parse($path, $data = '', $iso_fallback = false) { + $this->setDefaultPrefixes(); + /* reader */ + if (!$this->v('reader')) { + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->setAcceptHeader('Accept: application/x-turtle; q=0.9, */*; q=0.1'); + $this->reader->activate($path, $data); + $this->base = $this->v1('base', $this->reader->base, $this->a); + $this->r = array('vars' => array()); + /* parse */ + $buffer = ''; + $more_triples = array(); + $sub_v = ''; + $sub_v2 = ''; + $loops = 0; + $prologue_done = 0; + while ($d = $this->reader->readStream(0, 8192)) { + $buffer .= $d; + $sub_v = $buffer; + do { + $proceed = 0; + if (!$prologue_done) { + $proceed = 1; + if ((list($sub_r, $sub_v) = $this->xPrologue($sub_v)) && $sub_r) { + $loops = 0; + $sub_v .= $this->reader->readStream(0, 128); + /* we might have missed the final DOT in the previous prologue loop */ + if ($sub_r = $this->x('\.', $sub_v)) $sub_v = $sub_r[1]; + if ($this->x("\@?(base|prefix)", $sub_v)) {/* more prologue to come, use outer loop */ + $proceed = 0; + } + } + else { + $prologue_done = 1; + } + } + if ($prologue_done && (list($sub_r, $sub_v, $more_triples, $sub_v2) = $this->xTriplesBlock($sub_v)) && is_array($sub_r)) { + $proceed = 1; + $loops = 0; + foreach ($sub_r as $t) { + $this->addT($t); + } + } + } while ($proceed); + $loops++; + $buffer = $sub_v; + if ($loops > $this->max_parsing_loops) {/* most probably a parser or code bug, might also be a huge object value, though */ + $this->addError('too many loops: ' . $loops . '. Could not parse "' . substr($buffer, 0, 200) . '..."'); + break; + } + } + foreach ($more_triples as $t) { + $this->addT($t); + } + $sub_v = count($more_triples) ? $sub_v2 : $sub_v; + $buffer = $sub_v; + $this->unparsed_code = $buffer; + $this->reader->closeStream(); + unset($this->reader); + /* remove trailing comments */ + while (preg_match('/^\s*(\#[^\xd\xa]*)(.*)$/si', $this->unparsed_code, $m)) $this->unparsed_code = $m[2]; + if ($this->unparsed_code && !$this->getErrors()) { + $rest = preg_replace('/[\x0a|\x0d]/i', ' ', substr($this->unparsed_code, 0, 30)); + if (trim($rest)) $this->addError('Could not parse "' . $rest . '"'); + } + return $this->done(); + } + + function xPrologue($v) { + $r = 0; + if (!$this->t_count) { + if ((list($sub_r, $v) = $this->xBaseDecl($v)) && $sub_r) { + $this->base = $sub_r; + $r = 1; + } + while ((list($sub_r, $v) = $this->xPrefixDecl($v)) && $sub_r) { + $this->prefixes[$sub_r['prefix']] = $sub_r['uri']; + $r = 1; + } + } + return array($r, $v); + } + + /* 3 */ + + function xBaseDecl($v) { + if ($r = $this->x("\@?base\s+", $v)) { + if ((list($r, $sub_v) = $this->xIRI_REF($r[1])) && $r) { + if ($sub_r = $this->x('\.', $sub_v)) { + $sub_v = $sub_r[1]; + } + return array($r, $sub_v); + } + } + return array(0, $v); + } + + /* 4 */ + + function xPrefixDecl($v) { + if ($r = $this->x("\@?prefix\s+", $v)) { + if ((list($r, $sub_v) = $this->xPNAME_NS($r[1])) && $r) { + $prefix = $r; + if((list($r, $sub_v) = $this->xIRI_REF($sub_v)) && $r) { + $uri = $this->calcURI($r, $this->base); + if ($sub_r = $this->x('\.', $sub_v)) { + $sub_v = $sub_r[1]; + } + return array(array('prefix' => $prefix, 'uri_ref' => $r, 'uri' => $uri), $sub_v); + } + } + } + return array(0, $v); + } + + /* 21.., 32.. */ + + function xTriplesBlock($v) { + $pre_r = array(); + $r = array(); + $state = 1; + $sub_v = $v; + $buffer = $sub_v; + do { + $proceed = 0; + if ($state == 1) {/* expecting subject */ + $t = array('type' => 'triple', 's' => '', 'p' => '', 'o' => '', 's_type' => '', 'p_type' => '', 'o_type' => '', 'o_datatype' => '', 'o_lang' => ''); + if ((list($sub_r, $sub_v) = $this->xVarOrTerm($sub_v)) && $sub_r) { + $t['s'] = $sub_r['value']; + $t['s_type'] = $sub_r['type']; + $state = 2; + $proceed = 1; + if ($sub_r = $this->x('(\}|\.)', $sub_v)) { + if ($t['s_type'] == 'placeholder') { + $state = 4; + } + else { + $this->addError('"' . $sub_r[1]. '" after subject found.'); + } + } + } + elseif ((list($sub_r, $sub_v) = $this->xCollection($sub_v)) && $sub_r) { + $t['s'] = $sub_r['id']; + $t['s_type'] = $sub_r['type']; + $pre_r = array_merge($pre_r, $sub_r['triples']); + $state = 2; + $proceed = 1; + if ($sub_r = $this->x('\.', $sub_v)) { + $this->addError('DOT after subject found.'); + } + } + elseif ((list($sub_r, $sub_v) = $this->xBlankNodePropertyList($sub_v)) && $sub_r) { + $t['s'] = $sub_r['id']; + $t['s_type'] = $sub_r['type']; + $pre_r = array_merge($pre_r, $sub_r['triples']); + $state = 2; + $proceed = 1; + } + elseif ($sub_r = $this->x('\.', $sub_v)) { + $this->addError('Subject expected, DOT found.' . $sub_v); + } + } + if ($state == 2) {/* expecting predicate */ + if ($sub_r = $this->x('a\s+', $sub_v)) { + $sub_v = $sub_r[1]; + $t['p'] = $this->rdf . 'type'; + $t['p_type'] = 'uri'; + $state = 3; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xVarOrTerm($sub_v)) && $sub_r) { + if ($sub_r['type'] == 'bnode') { + $this->addError('Blank node used as triple predicate'); + } + $t['p'] = $sub_r['value']; + $t['p_type'] = $sub_r['type']; + $state = 3; + $proceed = 1; + } + elseif ($sub_r = $this->x('\.', $sub_v)) { + $state = 4; + } + elseif ($sub_r = $this->x('\}', $sub_v)) { + $buffer = $sub_v; + $r = array_merge($r, $pre_r); + $pre_r = array(); + $proceed = 0; + } + } + if ($state == 3) {/* expecting object */ + if ((list($sub_r, $sub_v) = $this->xVarOrTerm($sub_v)) && $sub_r) { + $t['o'] = $sub_r['value']; + $t['o_type'] = $sub_r['type']; + $t['o_lang'] = $this->v('lang', '', $sub_r); + $t['o_datatype'] = $this->v('datatype', '', $sub_r); + $pre_r[] = $t; + $state = 4; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xCollection($sub_v)) && $sub_r) { + $t['o'] = $sub_r['id']; + $t['o_type'] = $sub_r['type']; + $t['o_datatype'] = ''; + $pre_r = array_merge($pre_r, array($t), $sub_r['triples']); + $state = 4; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xBlankNodePropertyList($sub_v)) && $sub_r) { + $t['o'] = $sub_r['id']; + $t['o_type'] = $sub_r['type']; + $t['o_datatype'] = ''; + $pre_r = array_merge($pre_r, array($t), $sub_r['triples']); + $state = 4; + $proceed = 1; + } + } + if ($state == 4) {/* expecting . or ; or , or } */ + if ($sub_r = $this->x('\.', $sub_v)) { + $sub_v = $sub_r[1]; + $buffer = $sub_v; + $r = array_merge($r, $pre_r); + $pre_r = array(); + $state = 1; + $proceed = 1; + } + elseif ($sub_r = $this->x('\;', $sub_v)) { + $sub_v = $sub_r[1]; + $state = 2; + $proceed = 1; + } + elseif ($sub_r = $this->x('\,', $sub_v)) { + $sub_v = $sub_r[1]; + $state = 3; + $proceed = 1; + if ($sub_r = $this->x('\}', $sub_v)) { + $this->addError('Object expected, } found.'); + } + } + if ($sub_r = $this->x('(\}|\{|OPTIONAL|FILTER|GRAPH)', $sub_v)) { + $buffer = $sub_v; + $r = array_merge($r, $pre_r); + $pre_r = array(); + $proceed = 0; + } + } + } while ($proceed); + return count($r) ? array($r, $buffer, $pre_r, $sub_v) : array(0, $buffer, $pre_r, $sub_v); + } + + /* 39.. */ + + function xBlankNodePropertyList($v) { + if ($sub_r = $this->x('\[', $v)) { + $sub_v = $sub_r[1]; + $s = $this->createBnodeID(); + $r = array('id' => $s, 'type' => 'bnode', 'triples' => array()); + $t = array('type' => 'triple', 's' => $s, 'p' => '', 'o' => '', 's_type' => 'bnode', 'p_type' => '', 'o_type' => '', 'o_datatype' => '', 'o_lang' => ''); + $state = 2; + $closed = 0; + do { + $proceed = 0; + if ($state == 2) {/* expecting predicate */ + if ($sub_r = $this->x('a\s+', $sub_v)) { + $sub_v = $sub_r[1]; + $t['p'] = $this->rdf . 'type'; + $t['p_type'] = 'uri'; + $state = 3; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xVarOrTerm($sub_v)) && $sub_r) { + $t['p'] = $sub_r['value']; + $t['p_type'] = $sub_r['type']; + $state = 3; + $proceed = 1; + } + } + if ($state == 3) {/* expecting object */ + if ((list($sub_r, $sub_v) = $this->xVarOrTerm($sub_v)) && $sub_r) { + $t['o'] = $sub_r['value']; + $t['o_type'] = $sub_r['type']; + $t['o_lang'] = $this->v('lang', '', $sub_r); + $t['o_datatype'] = $this->v('datatype', '', $sub_r); + $r['triples'][] = $t; + $state = 4; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xCollection($sub_v)) && $sub_r) { + $t['o'] = $sub_r['id']; + $t['o_type'] = $sub_r['type']; + $t['o_datatype'] = ''; + $r['triples'] = array_merge($r['triples'], array($t), $sub_r['triples']); + $state = 4; + $proceed = 1; + } + elseif((list($sub_r, $sub_v) = $this->xBlankNodePropertyList($sub_v)) && $sub_r) { + $t['o'] = $sub_r['id']; + $t['o_type'] = $sub_r['type']; + $t['o_datatype'] = ''; + $r['triples'] = array_merge($r['triples'], array($t), $sub_r['triples']); + $state = 4; + $proceed = 1; + } + } + if ($state == 4) {/* expecting . or ; or , or ] */ + if ($sub_r = $this->x('\.', $sub_v)) { + $sub_v = $sub_r[1]; + $state = 1; + $proceed = 1; + } + if ($sub_r = $this->x('\;', $sub_v)) { + $sub_v = $sub_r[1]; + $state = 2; + $proceed = 1; + } + if ($sub_r = $this->x('\,', $sub_v)) { + $sub_v = $sub_r[1]; + $state = 3; + $proceed = 1; + } + if ($sub_r = $this->x('\]', $sub_v)) { + $sub_v = $sub_r[1]; + $proceed = 0; + $closed = 1; + } + } + } while ($proceed); + if ($closed) { + return array($r, $sub_v); + } + return array(0, $v); + } + return array(0, $v); + } + + /* 40.. */ + + function xCollection($v) { + if ($sub_r = $this->x('\(', $v)) { + $sub_v = $sub_r[1]; + $s = $this->createBnodeID(); + $r = array('id' => $s, 'type' => 'bnode', 'triples' => array()); + $closed = 0; + do { + $proceed = 0; + if ((list($sub_r, $sub_v) = $this->xVarOrTerm($sub_v)) && $sub_r) { + $r['triples'][] = array('type' => 'triple', 's' => $s, 'p' => $this->rdf . 'first', 'o' => $sub_r['value'], 's_type' => 'bnode', 'p_type' => 'uri', 'o_type' => $sub_r['type'], 'o_lang' => $this->v('lang', '', $sub_r), 'o_datatype' => $this->v('datatype', '', $sub_r)); + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xCollection($sub_v)) && $sub_r) { + $r['triples'][] = array('type' => 'triple', 's' => $s, 'p' => $this->rdf . 'first', 'o' => $sub_r['id'], 's_type' => 'bnode', 'p_type' => 'uri', 'o_type' => $sub_r['type'], 'o_lang' => '', 'o_datatype' => ''); + $r['triples'] = array_merge($r['triples'], $sub_r['triples']); + $proceed = 1; + } + elseif((list($sub_r, $sub_v) = $this->xBlankNodePropertyList($sub_v)) && $sub_r) { + $r['triples'][] = array('type' => 'triple', 's' => $s, 'p' => $this->rdf . 'first', 'o' => $sub_r['id'], 's_type' => 'bnode', 'p_type' => 'uri', 'o_type' => $sub_r['type'], 'o_lang' => '', 'o_datatype' => ''); + $r['triples'] = array_merge($r['triples'], $sub_r['triples']); + $proceed = 1; + } + if ($proceed) { + if ($sub_r = $this->x('\)', $sub_v)) { + $sub_v = $sub_r[1]; + $r['triples'][] = array('type' => 'triple', 's' => $s, 'p' => $this->rdf . 'rest', 'o' => $this->rdf . 'nil', 's_type' => 'bnode', 'p_type' => 'uri', 'o_type' => 'uri', 'o_lang' => '', 'o_datatype' => ''); + $closed = 1; + $proceed = 0; + } + else { + $next_s = $this->createBnodeID(); + $r['triples'][] = array('type' => 'triple', 's' => $s, 'p' => $this->rdf . 'rest', 'o' => $next_s, 's_type' => 'bnode', 'p_type' => 'uri', 'o_type' => 'bnode', 'o_lang' => '', 'o_datatype' => ''); + $s = $next_s; + } + } + } while ($proceed); + if ($closed) { + return array($r, $sub_v); + } + } + return array (0, $v); + } + + /* 42 */ + + function xVarOrTerm($v) { + if ((list($sub_r, $sub_v) = $this->xVar($v)) && $sub_r) { + return array($sub_r, $sub_v); + } + elseif ((list($sub_r, $sub_v) = $this->xGraphTerm($v)) && $sub_r) { + return array($sub_r, $sub_v); + } + return array(0, $v); + } + + /* 44, 74.., 75.. */ + + function xVar($v) { + if ($r = $this->x('(\?|\$)([^\s]+)', $v)) { + if ((list($sub_r, $sub_v) = $this->xVARNAME($r[2])) && $sub_r) { + if (!in_array($sub_r, $this->r['vars'])) { + $this->r['vars'][] = $sub_r; + } + return array(array('value' => $sub_r, 'type' => 'var'), $sub_v . $r[3]); + } + } + return array(0, $v); + } + + /* 45 */ + + function xGraphTerm($v) { + foreach (array( + 'IRIref' => 'uri', + 'RDFLiteral' => 'literal', + 'NumericLiteral' => 'literal', + 'BooleanLiteral' => 'literal', + 'BlankNode' => 'bnode', + 'NIL' => 'uri', + 'Placeholder' => 'placeholder' + ) as $term => $type) { + $m = 'x' . $term; + if ((list($sub_r, $sub_v) = $this->$m($v)) && $sub_r) { + if (!is_array($sub_r)) { + $sub_r = array('value' => $sub_r); + } + $sub_r['type'] = $this->v1('type', $type, $sub_r); + return array($sub_r, $sub_v); + } + } + return array(0, $v); + } + + /* 60 */ + + function xRDFLiteral($v) { + if ((list($sub_r, $sub_v) = $this->xString($v)) && $sub_r) { + $sub_r['value'] = $this->unescapeNtripleUTF($sub_r['value']); + $r = $sub_r; + if ((list($sub_r, $sub_v) = $this->xLANGTAG($sub_v)) && $sub_r) { + $r['lang'] = $sub_r; + } + elseif (!$this->x('\s', $sub_v) && ($sub_r = $this->x('\^\^', $sub_v)) && (list($sub_r, $sub_v) = $this->xIRIref($sub_r[1])) && $sub_r[1]) { + $r['datatype'] = $sub_r; + } + return array($r, $sub_v); + } + return array(0, $v); + } + + /* 61.., 62.., 63.., 64.. */ + + function xNumericLiteral($v) { + $sub_r = $this->x('(\-|\+)?', $v); + $prefix = $sub_r[1]; + $sub_v = $sub_r[2]; + foreach (array('DOUBLE' => 'double', 'DECIMAL' => 'decimal', 'INTEGER' => 'integer') as $type => $xsd) { + $m = 'x' . $type; + if ((list($sub_r, $sub_v) = $this->$m($sub_v)) && ($sub_r !== false)) { + $r = array('value' => $prefix . $sub_r, 'type' => 'literal', 'datatype' => $this->xsd . $xsd); + return array($r, $sub_v); + } + } + return array(0, $v); + } + + /* 65.. */ + + function xBooleanLiteral($v) { + if ($r = $this->x('(true|false)', $v)) { + return array($r[1], $r[2]); + } + return array(0, $v); + } + + /* 66.., 87.., 88.., 89.., 90.., 91.. */ + + function xString($v) {/* largely simplified, may need some tweaks in following revisions */ + $sub_v = $v; + if (!preg_match('/^\s*([\']{3}|\'|[\"]{3}|\")(.*)$/s', $sub_v, $m)) return array(0, $v); + $delim = $m[1]; + $rest = $m[2]; + $sub_types = array("'''" => 'literal_long1', '"""' => 'literal_long2', "'" => 'literal1', '"' => 'literal2'); + $sub_type = $sub_types[$delim]; + $pos = 0; + $r = false; + do { + $proceed = 0; + $delim_pos = strpos($rest, $delim, $pos); + if ($delim_pos === false) break; + $new_rest = substr($rest, $delim_pos + strlen($delim)); + $r = substr($rest, 0, $delim_pos); + if (!preg_match('/([\x5c]+)$/s', $r, $m) || !(strlen($m[1]) % 2)) { + $rest = $new_rest; + } + else { + $r = false; + $pos = $delim_pos + 1; + $proceed = 1; + } + } while ($proceed); + if ($r !== false) { + return array(array('value' => $this->toUTF8($r) , 'type' => 'literal', 'sub_type' => $sub_type), $rest); + } + return array(0, $v); + } + + /* 67 */ + + function xIRIref($v) { + if ((list($r, $v) = $this->xIRI_REF($v)) && $r) { + return array($this->calcURI($r, $this->base), $v); + } + elseif ((list($r, $v) = $this->xPrefixedName($v)) && $r) { + return array($r, $v); + } + return array(0, $v); + } + + /* 68 */ + + function xPrefixedName($v) { + if ((list($r, $v) = $this->xPNAME_LN($v)) && $r) { + return array($r, $v); + } + elseif ((list($r, $sub_v) = $this->xPNAME_NS($v)) && $r) { + return isset($this->prefixes[$r]) ? array($this->prefixes[$r], $sub_v) : array(0, $v); + } + return array(0, $v); + } + + /* 69.., 73.., 93, 94.. */ + + function xBlankNode($v) { + if (($r = $this->x('\_\:', $v)) && (list($r, $sub_v) = $this->xPN_LOCAL($r[1])) && $r) { + return array(array('type' => 'bnode', 'value' => '_:' . $r), $sub_v); + } + if ($r = $this->x('\[[\x20\x9\xd\xa]*\]', $v)) { + return array(array('type' => 'bnode', 'value' => $this->createBnodeID()), $r[1]); + } + return array(0, $v); + } + + /* 70.. @@sync with SPARQLParser */ + + function xIRI_REF($v) { + //if ($r = $this->x('\<([^\<\>\"\{\}\|\^\'[:space:]]*)\>', $v)) { + if (($r = $this->x('\<(\$\{[^\>]*\})\>', $v)) && ($sub_r = $this->xPlaceholder($r[1]))) { + return array($r[1], $r[2]); + } + elseif ($r = $this->x('\<\>', $v)) { + return array(true, $r[1]); + } + elseif ($r = $this->x('\<([^\s][^\<\>]*)\>', $v)) { + return array($r[1] ? $r[1] : true, $r[2]); + } + return array(0, $v); + } + + /* 71 */ + + function xPNAME_NS($v) { + list($r, $sub_v) = $this->xPN_PREFIX($v); + $prefix = $r ? $r : ''; + return ($r = $this->x("\:", $sub_v)) ? array($prefix . ':', $r[1]) : array(0, $v); + } + + /* 72 */ + + function xPNAME_LN($v) { + if ((list($r, $sub_v) = $this->xPNAME_NS($v)) && $r) { + if (!$this->x('\s', $sub_v) && (list($sub_r, $sub_v) = $this->xPN_LOCAL($sub_v)) && $sub_r) { + if (!isset($this->prefixes[$r])) { + return array(0, $v); + } + return array($this->prefixes[$r] . $sub_r, $sub_v); + } + } + return array(0, $v); + } + + /* 76 */ + + function xLANGTAG($v) { + if (!$this->x('\s', $v) && ($r = $this->x('\@([a-z]+(\-[a-z0-9]+)*)', $v))) { + return array($r[1], $r[3]); + } + return array(0, $v); + } + + /* 77.. */ + + function xINTEGER($v) { + if ($r = $this->x('([0-9]+)', $v)) { + return array($r[1], $r[2]); + } + return array(false, $v); + } + + /* 78.. */ + + function xDECIMAL($v) { + if ($r = $this->x('([0-9]+\.[0-9]*)', $v)) { + return array($r[1], $r[2]); + } + if ($r = $this->x('(\.[0-9]+)', $v)) { + return array($r[1], $r[2]); + } + return array(false, $v); + } + + /* 79.., 86.. */ + + function xDOUBLE($v) { + if ($r = $this->x('([0-9]+\.[0-9]*E[\+\-]?[0-9]+)', $v)) { + return array($r[1], $r[2]); + } + if ($r = $this->x('(\.[0-9]+E[\+\-]?[0-9]+)', $v)) { + return array($r[1], $r[2]); + } + if ($r = $this->x('([0-9]+E[\+\-]?[0-9]+)', $v)) { + return array($r[1], $r[2]); + } + return array(false, $v); + } + + /* 92 */ + + function xNIL($v) { + if ($r = $this->x('\([\x20\x9\xd\xa]*\)', $v)) { + return array(array('type' => 'uri', 'value' => $this->rdf . 'nil'), $r[1]); + } + return array(0, $v); + } + + /* 95.. */ + + function xPN_CHARS_BASE($v) { + if ($r = $this->x("([a-z]+|\\\u[0-9a-f]{1,4})", $v)) { + return array($r[1], $r[2]); + } + return array(0, $v); + } + + /* 96 */ + + function xPN_CHARS_U($v) { + if ((list($r, $sub_v) = $this->xPN_CHARS_BASE($v)) && $r) { + return array($r, $sub_v); + } + elseif ($r = $this->x("(_)", $v)) { + return array($r[1], $r[2]); + } + return array(0, $v); + } + + /* 97.. */ + + function xVARNAME($v) { + $r = ''; + do { + $proceed = 0; + if ($sub_r = $this->x('([0-9]+)', $v)) { + $r .= $sub_r[1]; + $v = $sub_r[2]; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xPN_CHARS_U($v)) && $sub_r) { + $r .= $sub_r; + $v = $sub_v; + $proceed = 1; + } + elseif ($r && ($sub_r = $this->x('([\xb7\x300-\x36f]+)', $v))) { + $r .= $sub_r[1]; + $v = $sub_r[2]; + $proceed = 1; + } + } while ($proceed); + return array($r, $v); + } + + /* 98.. */ + + function xPN_CHARS($v) { + if ((list($r, $sub_v) = $this->xPN_CHARS_U($v)) && $r) { + return array($r, $sub_v); + } + elseif ($r = $this->x('([\-0-9\xb7\x300-\x36f])', $v)) { + return array($r[1], $r[2]); + } + return array(false, $v); + } + + /* 99 */ + + function xPN_PREFIX($v) { + if ($sub_r = $this->x("([^\s\:\(\)\{\}\;\,]+)", $v, 's')) {/* accelerator */ + return array($sub_r[1], $sub_r[2]);/* @@testing */ + } + if ((list($r, $sub_v) = $this->xPN_CHARS_BASE($v)) && $r) { + do { + $proceed = 0; + list($sub_r, $sub_v) = $this->xPN_CHARS($sub_v); + if ($sub_r !== false) { + $r .= $sub_r; + $proceed = 1; + } + elseif ($sub_r = $this->x("\.", $sub_v)) { + $r .= '.'; + $sub_v = $sub_r[1]; + $proceed = 1; + } + } while ($proceed); + list($sub_r, $sub_v) = $this->xPN_CHARS($sub_v); + $r .= $sub_r ? $sub_r : ''; + } + return array($r, $sub_v); + } + + /* 100 */ + + function xPN_LOCAL($v) { + if (($sub_r = $this->x("([^\s\(\)\{\}\[\]\;\,\.]+)", $v, 's')) && !preg_match('/^\./', $sub_r[2])) {/* accelerator */ + return array($sub_r[1], $sub_r[2]);/* @@testing */ + } + $r = ''; + $sub_v = $v; + do { + $proceed = 0; + if ($this->x('\s', $sub_v)) { + return array($r, $sub_v); + } + if ($sub_r = $this->x('([0-9])', $sub_v)) { + $r .= $sub_r[1]; + $sub_v = $sub_r[2]; + $proceed = 1; + } + elseif ((list($sub_r, $sub_v) = $this->xPN_CHARS_U($sub_v)) && $sub_r) { + $r .= $sub_r; + $proceed = 1; + } + elseif ($r) { + if (($sub_r = $this->x('(\.)', $sub_v)) && !preg_match('/^[\s\}]/s', $sub_r[2])) { + $r .= $sub_r[1]; + $sub_v = $sub_r[2]; + } + if ((list($sub_r, $sub_v) = $this->xPN_CHARS($sub_v)) && $sub_r) { + $r .= $sub_r; + $proceed = 1; + } + } + } while ($proceed); + return array($r, $sub_v); + } + + /* */ + + function unescapeNtripleUTF($v) { + if (strpos($v, '\\') === false) return $v; + $mappings = array('t' => "\t", 'n' => "\n", 'r' => "\r", '\"' => '"', '\'' => "'"); + foreach ($mappings as $in => $out) { + $v = preg_replace('/\x5c([' . $in . '])/', $out, $v); + } + if (strpos(strtolower($v), '\u') === false) return $v; + while (preg_match('/\\\(U)([0-9A-F]{8})/', $v, $m) || preg_match('/\\\(u)([0-9A-F]{4})/', $v, $m)) { + $no = hexdec($m[2]); + if ($no < 128) $char = chr($no); + else if ($no < 2048) $char = chr(($no >> 6) + 192) . chr(($no & 63) + 128); + else if ($no < 65536) $char = chr(($no >> 12) + 224) . chr((($no >> 6) & 63) + 128) . chr(($no & 63) + 128); + else if ($no < 2097152) $char = chr(($no >> 18) + 240) . chr((($no >> 12) & 63) + 128) . chr((($no >> 6) & 63) + 128) . chr(($no & 63) + 128); + else $char= ''; + $v = str_replace('\\' . $m[1] . $m[2], $char, $v); + } + return $v; + } + + /* */ + + function xPlaceholder($v) { + //if ($r = $this->x('(\?|\$)\{([^\}]+)\}', $v)) { + if ($r = $this->x('(\?|\$)', $v)) { + if (preg_match('/(\{(?:[^{}]+|(?R))*\})/', $r[2], $m) && strpos(trim($r[2]), $m[1]) === 0) { + $ph = substr($m[1], 1, -1); + $rest = substr(trim($r[2]), strlen($m[1])); + if (!isset($this->r['placeholders'])) $this->r['placeholders'] = array(); + if (!in_array($ph, $this->r['placeholders'])) $this->r['placeholders'][] = $ph; + return array(array('value' => $ph, 'type' => 'placeholder'), $rest); + } + } + return array(0, $v); + } + + /* */ +} diff --git a/arc2-2.2.4/serializers/ARC2_LegacyHTMLSerializer.php b/arc2-2.2.4/serializers/ARC2_LegacyHTMLSerializer.php new file mode 100755 index 0000000..81563ba --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_LegacyHTMLSerializer.php @@ -0,0 +1,111 @@ +content_header = 'text/html'; + } + + /* */ + + function getSerializedArray($struct, $root = 1, $ind = ' ') { + $n = "\n"; + $r = ''; + $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; + foreach ($struct as $k => $v) { + if (!$is_flat) $r .= $n . $ind . $ind . '
' . $k . '
'; + $r .= $n . $ind . $ind . '
' . (is_array($v) ? $this->getSerializedArray($v, 0, $ind . $ind . $ind) . $n . $ind . $ind : htmlspecialchars($v)) . '
'; + } + return $n . $ind . '
' . $r . $n . $ind . '
'; + } + + /* */ + + function isAssociativeArray($v) { + foreach (array_keys($v) as $k => $val) { + if ($k !== $val) return 1; + } + return 0; + } + + /* */ + + function getSerializedNode($index, $node, $level = 0, $raw = 0) { + $r = ''; + $tag = $this->v('tag', '', $node); + if (preg_match('/^(comment|script)$/', $tag)) { + } + elseif ($tag == 'cdata') { + $r .= $this->v('cdata', '', $node); + $r .= $this->v('value', '', $node['a']); + } + else { + /* open tag */ + if (preg_match('/^(div|form|p|section)$/', $tag)) { + $r .= str_pad("\n", $level + 1, " "); + } + $r .= '<' . $tag; + $attrs = $this->v('a', array(), $node); + foreach ($attrs as $k => $v) { + /* use uri, if detected */ + if ($k != 'id') { + $v = $this->v($k . ' uri', $v, $attrs); + } + /* skip arrays and other derived attrs */ + if (preg_match('/\s/s', $k)) continue; + $r .= ' ' . $k . '="' . $v . '"'; + } + if ($node['empty']) { + $r .= '/>'; + } + else { + $r .= '>'; + /* cdata */ + $r .= $this->v('cdata', '', $node); + /* sub-nodes */ + $sub_nodes = $this->v($node['id'], array(), $index); + foreach ($sub_nodes as $sub_node) { + $r .= $this->getSerializedNode($index, $sub_node, $level + 1, 1); + } + /* close tag */ + //$r .= str_pad("\n", $level + 1, " ") . ''; + $r .= ''; + if (preg_match('/^(div|form|p|section)$/', $tag)) { + $r .= str_pad("\n", $level + 1, " "); + } + } + } + /* doc envelope, in case of sub-structure serializing */ + if (!$raw && ($level == 0) && ($node['level'] > 1)) { + $r = ' + + + + + + ' . $r . ' + + + '; + } + return $r; + } + + /* */ +} + diff --git a/arc2-2.2.4/serializers/ARC2_LegacyJSONSerializer.php b/arc2-2.2.4/serializers/ARC2_LegacyJSONSerializer.php new file mode 100755 index 0000000..35aa726 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_LegacyJSONSerializer.php @@ -0,0 +1,53 @@ +content_header = 'application/json'; + } + + /* */ + + function getSerializedArray($struct, $ind = '') { + $n = "\n"; + if (function_exists('json_encode')) return str_replace('","', '",' . $n . '"', str_replace("\/","/",json_encode($struct))); + $r = ''; + $from = array("\\", "\r", "\t", "\n", '"', "\b", "\f"); + $to = array('\\\\', '\r', '\t', '\n', '\"', '\b', '\f'); + $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; + foreach ($struct as $k => $v) { + $r .= $r ? ',' . $n . $ind . $ind : $ind . $ind; + $r .= $is_flat ? '' : '"' . $k . '": '; + $r .= is_array($v) ? $this->getSerializedArray($v, $ind . ' ') : '"' . str_replace($from, $to, $v) . '"'; + } + return $is_flat ? $ind . '[' . $n . $r . $n . $ind . ']' : $ind . '{' . $n . $r . $n . $ind . '}'; + } + + /* */ + + function isAssociativeArray($v) { + foreach (array_keys($v) as $k => $val) { + if ($k !== $val) return 1; + } + return 0; + } + + /* */ + +} + diff --git a/arc2-2.2.4/serializers/ARC2_LegacyXMLSerializer.php b/arc2-2.2.4/serializers/ARC2_LegacyXMLSerializer.php new file mode 100755 index 0000000..a401887 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_LegacyXMLSerializer.php @@ -0,0 +1,66 @@ +content_header = 'text/xml'; + } + + /* */ + + function getSerializedArray($struct, $root = 1, $ind = ' ') { + $n = "\n"; + $r = ''; + $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; + foreach ($struct as $k => $v) { + $tag = $is_flat ? 'item' : preg_replace('/[\s]/s', '_', $k); + $tag = preg_replace('/^.*([a-z0-9\-\_]+)$/Uis', '\\1', $tag); + $r .= $n . $ind . '<' . $tag . '>' . (is_array($v) ? $this->getSerializedArray($v, 0, $ind . ' ') . $n . $ind : htmlspecialchars($v)) . ''; + } + if ($root) $r = $this->getHead() . $r . $this->getFooter(); + return $r; + } + + /* */ + + function getHead() { + $n = "\n"; + $r = ''; + $r .= $n . ''; + return $r; + } + + function getFooter() { + $n = "\n"; + $r = $n . ''; + return $r; + } + + /* */ + + function isAssociativeArray($v) { + foreach (array_keys($v) as $k => $val) { + if ($k !== $val) return 1; + } + return 0; + } + + /* */ + +} + diff --git a/arc2-2.2.4/serializers/ARC2_MicroRDFSerializer.php b/arc2-2.2.4/serializers/ARC2_MicroRDFSerializer.php new file mode 100755 index 0000000..c08a3ce --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_MicroRDFSerializer.php @@ -0,0 +1,142 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFSerializer'); + +class ARC2_MicroRDFSerializer extends ARC2_RDFSerializer { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->content_header = 'text/html'; + $this->label_store = $this->v('label_store', '', $this->a); + } + + /* */ + + function getLabel($res, $ps = '') { + if (!$ps) $ps = array(); + foreach ($ps as $p => $os) { + if (preg_match('/[\/\#](name|label|summary|title|fn)$/i', $p)) { + return $os[0]['value']; + } + } + if (preg_match('/^\_\:/', $res)) return "An unnamed resource"; + return $this->extractTermLabel($res); + return preg_replace("/^(.*[\/\#])([^\/\#]+)$/", '\\2', str_replace('_', ' ', $res)); + } + + function getSerializedIndex($index, $res = '') { + $r = ''; + $n = "\n"; + if ($res) $index = array($res => $index[$res]); + //return Trice::dump($index); + $types = $this->v($this->expandPName('rdf:type'), array(), $index); + $main_type = $types ? $types[0]['value'] : ''; + foreach ($index as $s => $ps) { + /* node */ + $r .= ' +
mdAttrs($s, $main_type) . '> +

' . ucfirst($this->getLabel($s, $ps)) . '

+ '; + /* arcs */ + foreach ($ps as $p => $os) { + $p_cls = strtolower($this->getPName($p)); + $p_cls = str_replace(':', '-', $p_cls); + $r .= ' +
+ ' . ucfirst($this->getLabel($p)) . ': +
    + '; + $oc = count($os); + foreach ($os as $i => $o) { + $val = $this->getObjectValue($o, $p); + $cls = ''; + if ($i == 0) $cls .= ($cls ? ' ' : '') . 'first'; + if ($i == $oc - 1) $cls .= ($cls ? ' ' : '') . 'last'; + $r .= $n . '' . $val . ''; + } + $r .= ' +
+
+
+ '; + } + /* /node */ + $r .= ' +
+
+ '; + } + return $r; + } + + function getObjectValue($o, $p) { + if ($o['type'] == 'uri') { + if (preg_match('/(jpe?g|gif|png)$/i', $o['value'])) { + return $this->getImageObjectValue($o, $p); + } + return $this->getURIObjectValue($o, $p); + } + if ($o['type'] == "bnode") { + return $this->getBNodeObjectValue($o, $p); + } + return $this->getLiteralObjectValue($o, $p); + } + + function getImageObjectValue($o, $p) { + return 'img'; + } + + function getURIObjectValue($o, $p) { + $id = htmlspecialchars($o['value']); + $label = $this->getObjectLabel($o['value']); + /* differing href */ + $href = htmlspecialchars($this->v('href', $o['value'], $o)); + if ($id != $href) { + return '' . $label . ''; + } + return '' . $label . ''; + //$label = $o['value']; + //$label = preg_replace('/^https?\:\/\/(www\.)?/', '', $label); + } + + function getBNodeObjectValue($o, $p) { + return '
' . $o['value'] . '
'; + return '
An unnamed resource
'; + } + + function getLiteralObjectValue($o, $p) { + return '
' . $o['value'] . '
'; + } + + /* */ + + function getObjectLabel($id) { + $r = $this->extractTermLabel($id); + if (!$this->label_store) return $r; + $q = ' + SELECT ?val WHERE { + <' . $id . '> ?p ?val . + FILTER(REGEX(str(?p), "(label|title|name|summary)$")) + } LIMIT 1 + '; + $row = $this->label_store->query($q, 'row'); + return $row ? $row['val'] : $r; + } + + /* */ + +} + diff --git a/arc2-2.2.4/serializers/ARC2_NTriplesSerializer.php b/arc2-2.2.4/serializers/ARC2_NTriplesSerializer.php new file mode 100755 index 0000000..6e95352 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_NTriplesSerializer.php @@ -0,0 +1,192 @@ + + * @homepage + * @package ARC2 +*/ + +ARC2::inc('RDFSerializer'); + +class ARC2_NTriplesSerializer extends ARC2_RDFSerializer { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->esc_chars = array(); + $this->raw = 0; + } + + /* */ + + function getTerm($v, $term = '') { + // type detection + if (!is_array($v) || empty($v['type'])) { + // bnode + if (preg_match('/^\_\:/', $v)) { + return $this->getTerm(array('value' => $v, 'type' => 'bnode')); + } + // uri + if (preg_match('/^[a-z0-9]+\:[^\s\"]*$/is' . ($this->has_pcre_unicode ? 'u' : ''), $v)) { + return $this->getTerm(array('value' => $v, 'type' => 'uri')); + } + // fallback for non-unicode environments: subjects and predicates can't be literals. + if (in_array($term, array('s', 'p'))) { + return $this->getTerm(array('value' => $v, 'type' => 'uri')); + } + // assume literal + return $this->getTerm(array('type' => 'literal', 'value' => $v)); + } + if ($v['type'] == 'bnode') { + return $v['value']; + } + elseif ($v['type'] == 'uri') { + return '<' . $this->escape($v['value']) . '>'; + } + // something went wrong + elseif ($v['type'] != 'literal') { + return $this->getTerm($v['value']); + } + /* literal */ + $quot = '"'; + if ($this->raw && preg_match('/\"/', $v['value'])) { + $quot = "'"; + if (preg_match('/\'/', $v['value'])) { + $quot = '"""'; + if (preg_match('/\"\"\"/', $v['value']) || preg_match('/\"$/', $v['value']) || preg_match('/^\"/', $v['value'])) { + $quot = "'''"; + $v['value'] = preg_replace("/'$/", "' ", $v['value']); + $v['value'] = preg_replace("/^'/", " '", $v['value']); + $v['value'] = str_replace("'''", '\\\'\\\'\\\'', $v['value']); + } + } + } + if ($this->raw && (strlen($quot) == 1) && preg_match('/[\x0d\x0a]/', $v['value'])) { + $quot = $quot . $quot . $quot; + } + $suffix = isset($v['lang']) && $v['lang'] ? '@' . $v['lang'] : ''; + $suffix = isset($v['datatype']) && $v['datatype'] ? '^^' . $this->getTerm($v['datatype']) : $suffix; + //return $quot . "object" . utf8_encode($v['value']) . $quot . $suffix; + return $quot . $this->escape($v['value']) . $quot . $suffix; + } + + function getSerializedIndex($index, $raw = 0) { + $this->raw = $raw; + $r = ''; + $nl = "\n"; + foreach ($index as $s => $ps) { + $s = $this->getTerm($s, 's'); + foreach ($ps as $p => $os) { + $p = $this->getTerm($p, 'p'); + if (!is_array($os)) {/* single literal o */ + $os = array(array('value' => $os, 'type' => 'literal')); + } + foreach ($os as $o) { + $o = $this->getTerm($o, 'o‚'); + $r .= $r ? $nl : ''; + $r .= $s . ' ' . $p . ' ' . $o . ' .'; + } + } + } + return $r . $nl; + } + + /* */ + + function escape($v) { + $r = ''; + // decode, if possible + $v = (strpos(utf8_decode(str_replace('?', '', $v)), '?') === false) ? utf8_decode($v) : $v; + if ($this->raw) return $v;// no further escaping wanted + // escape tabs and linefeeds + $v = str_replace(array("\t", "\r", "\n"), array('\t', '\r', '\n'), $v); + // escape non-ascii-chars + $v = preg_replace_callback('/([^a-zA-Z0-9 \!\#\$\%\&\(\)\*\+\,\-\.\/\:\;\=\?\@\^\_\{\|\}]+)/', array($this, 'escapeChars'), $v); + return $v; + } + + function escapeChars($matches) { + $v = $matches[1]; + $r = ''; + // loop through mb chars + if (function_exists('mb_strlen')) { + for ($i = 0, $i_max = mb_strlen($v, 'UTF-8'); $i < $i_max; $i++) { + $c = mb_substr($v, $i, 1, 'UTF-8'); + if (!isset($this->esc_chars[$c])) { + $this->esc_chars[$c] = $this->getEscapedChar($c, $this->getCharNo($c, 1)); + } + $r .= $this->esc_chars[$c]; + } + } + // fall back to built-in JSON functionality, if available + else if (function_exists('json_encode')) { + $r = json_encode($v); + if ($r == 'null') $r = json_encode (utf8_encode($v)); + // remove boundary quotes + if (substr($r, 0, 1) == '"') $r = substr($r, 1); + if (substr($r, -1) == '"') $r = substr($r, 0, -1); + // uppercase hex chars + $r = preg_replace('/(\\\u)([0-9a-f]{4})/e', "'\\1' . strtoupper('\\2')", $r); + $r = preg_replace('/(\\\U)([0-9a-f]{8})/e', "'\\1' . strtoupper('\\2')", $r); + } + // escape byte-wise (may be wrong for mb chars and newer php versions) + else { + for ($i = 0, $i_max = strlen($v); $i < $i_max; $i++) { + $c = $v[$i]; + if (!isset($this->esc_chars[$c])) { + $this->esc_chars[$c] = $this->getEscapedChar($c, $this->getCharNo($c)); + } + $r .= $this->esc_chars[$c]; + } + } + return $r; + } + + /* */ + + function getCharNo($c, $is_encoded = false) { + $c_utf = $is_encoded ? $c : utf8_encode($c); + $bl = strlen($c_utf);/* binary length */ + $r = 0; + switch ($bl) { + case 1:/* 0####### (0-127) */ + $r = ord($c_utf); + break; + case 2:/* 110##### 10###### = 192+x 128+x */ + $r = ((ord($c_utf[0]) - 192) * 64) + (ord($c_utf[1]) - 128); + break; + case 3:/* 1110#### 10###### 10###### = 224+x 128+x 128+x */ + $r = ((ord($c_utf[0]) - 224) * 4096) + ((ord($c_utf[1]) - 128) * 64) + (ord($c_utf[2]) - 128); + break; + case 4:/* 1111#### 10###### 10###### 10###### = 240+x 128+x 128+x 128+x */ + $r = ((ord($c_utf[0]) - 240) * 262144) + ((ord($c_utf[1]) - 128) * 4096) + ((ord($c_utf[2]) - 128) * 64) + (ord($c_utf[3]) - 128); + break; + } + return $r; + } + + function getEscapedChar($c, $no) {/*see http://www.w3.org/TR/rdf-testcases/#ntrip_strings */ + if ($no < 9) return "\\u" . sprintf('%04X', $no); /* #x0-#x8 (0-8) */ + if ($no == 9) return '\t'; /* #x9 (9) */ + if ($no == 10) return '\n'; /* #xA (10) */ + if ($no < 13) return "\\u" . sprintf('%04X', $no); /* #xB-#xC (11-12) */ + if ($no == 13) return '\r'; /* #xD (13) */ + if ($no < 32) return "\\u" . sprintf('%04X', $no); /* #xE-#x1F (14-31) */ + if ($no < 34) return $c; /* #x20-#x21 (32-33) */ + if ($no == 34) return '\"'; /* #x22 (34) */ + if ($no < 92) return $c; /* #x23-#x5B (35-91) */ + if ($no == 92) return '\\'; /* #x5C (92) */ + if ($no < 127) return $c; /* #x5D-#x7E (93-126) */ + if ($no < 65536) return "\\u" . sprintf('%04X', $no); /* #x7F-#xFFFF (128-65535) */ + if ($no < 1114112) return "\\U" . sprintf('%08X', $no); /* #x10000-#x10FFFF (65536-1114111) */ + return ''; /* not defined => ignore */ + } + + /* */ + +} diff --git a/arc2-2.2.4/serializers/ARC2_POSHRDFSerializer.php b/arc2-2.2.4/serializers/ARC2_POSHRDFSerializer.php new file mode 100755 index 0000000..8edd15d --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_POSHRDFSerializer.php @@ -0,0 +1,105 @@ +content_header = 'text/html'; + } + + /* */ + + function getLabel($res, $ps = '') { + if (!$ps) $ps = array(); + foreach ($ps as $p => $os) { + if (preg_match('/[\/\#](name|label|summary|title|fn)$/i', $p)) { + return $os[0]['value']; + } + } + if (preg_match('/^\_\:/', $res)) return "An unnamed resource"; + return preg_replace("/^(.*[\/\#])([^\/\#]+)$/", '\\2', str_replace('_', ' ', $res)); + } + + function getSerializedIndex($index, $res = '') { + $r = ''; + $n = "\n"; + if ($res) $index = array($res => $index[$res]); + //return Trice::dump($index); + foreach ($index as $s => $ps) { + /* node */ + $r .= ' +
+

' . $this->getLabel($s, $ps) . '

+ '; + /* arcs */ + foreach ($ps as $p => $os) { + $r .= ' +
+ ' . ucfirst($this->getLabel($p)) . ' + '; + foreach ($os as $o) { + $r .= $n . $this->getObjectValue($o); + } + $r .= ' +
+ '; + } + /* node */ + $r .= ' +
+
+ '; + } + return $r; + } + + function getObjectValue($o) { + if ($o['type'] == 'uri') { + if (preg_match('/(jpe?g|gif|png)$/i', $o['value'])) { + return $this->getImageObjectValue($o); + } + return $this->getURIObjectValue($o); + } + if ($o['type'] == "bnode") { + return $this->getBNodeObjectValue($o); + } + return $this->getLiteralObjectValue($o); + } + + function getImageObjectValue($o) { + return 'img'; + } + + function getURIObjectValue($o) { + $href = htmlspecialchars($o['value']); + $label = $o['value']; + $label = preg_replace('/^https?\:\/\/(www\.)?/', '', $label); + return '' . $label . ''; + } + + function getBNodeObjectValue($o) { + return '
An unnamed resource
'; + } + + function getLiteralObjectValue($o) { + return '
' . $o['value'] . '
'; + } + + /* */ + +} + diff --git a/arc2-2.2.4/serializers/ARC2_RDFJSONSerializer.php b/arc2-2.2.4/serializers/ARC2_RDFJSONSerializer.php new file mode 100755 index 0000000..8cc90a1 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_RDFJSONSerializer.php @@ -0,0 +1,89 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 +*/ + +ARC2::inc('RDFSerializer'); + +class ARC2_RDFJSONSerializer extends ARC2_RDFSerializer { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->content_header = 'application/json'; + } + + /* */ + + function getTerm($v, $term = 's') { + if (!is_array($v)) { + if (preg_match('/^\_\:/', $v)) { + return ($term == 'o') ? $this->getTerm(array('value' => $v, 'type' => 'bnode'), 'o') : '"' . $v . '"'; + } + return ($term == 'o') ? $this->getTerm(array('value' => $v, 'type' => 'uri'), 'o') : '"' . $v . '"'; + } + if (!isset($v['type']) || ($v['type'] != 'literal')) { + if ($term != 'o') { + return $this->getTerm($v['value'], $term); + } + if (preg_match('/^\_\:/', $v['value'])) { + return '{ "value" : "' . $this->jsonEscape($v['value']) . '", "type" : "bnode" }'; + } + return '{ "value" : "' . $this->jsonEscape($v['value']) . '", "type" : "uri" }'; + } + /* literal */ + $r = '{ "value" : "' . $this->jsonEscape($v['value']) . '", "type" : "literal"'; + $suffix = isset($v['datatype']) ? ', "datatype" : "' . $v['datatype'] . '"' : ''; + $suffix = isset($v['lang']) ? ', "lang" : "' . $v['lang'] . '"' : $suffix; + $r .= $suffix . ' }'; + return $r; + } + + function jsonEscape($v) { + if (function_exists('json_encode')) { + return preg_replace('/^"(.*)"$/', '\\1', str_replace("\/","/",json_encode($v))); + } + $from = array("\\", "\r", "\t", "\n", '"', "\b", "\f"); + $to = array('\\\\', '\r', '\t', '\n', '\"', '\b', '\f'); + return str_replace($from, $to, $v); + } + + function getSerializedIndex($index, $raw = 0) { + $r = ''; + $nl = "\n"; + foreach ($index as $s => $ps) { + $r .= $r ? ',' . $nl . $nl : ''; + $r .= ' ' . $this->getTerm($s). ' : {'; + $first_p = 1; + foreach ($ps as $p => $os) { + $r .= $first_p ? $nl : ',' . $nl; + $r .= ' ' . $this->getTerm($p). ' : ['; + $first_o = 1; + if (!is_array($os)) {/* single literal o */ + $os = array(array('value' => $os, 'type' => 'literal')); + } + foreach ($os as $o) { + $r .= $first_o ? $nl : ',' . $nl; + $r .= ' ' . $this->getTerm($o, 'o'); + $first_o = 0; + } + $first_p = 0; + $r .= $nl . ' ]'; + } + $r .= $nl . ' }'; + } + $r .= $r ? ' ' : ''; + return '{' . $nl . $r . $nl . '}'; + } + + /* */ + +} diff --git a/arc2-2.2.4/serializers/ARC2_RDFSerializer.php b/arc2-2.2.4/serializers/ARC2_RDFSerializer.php new file mode 100755 index 0000000..c9034ab --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_RDFSerializer.php @@ -0,0 +1,53 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_RDFSerializer extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + foreach ($this->ns as $k => $v) { + $this->nsp[$v] = $k; + } + } + + /* */ + + function xgetPName($v) {/* moved to merged getPName in ARC2_CLass */ + if (preg_match('/^([a-z0-9\_\-]+)\:([a-z\_][a-z0-9\_\-]*)$/i', $v, $m) && isset($this->ns[$m[1]])) { + $this->used_ns = !in_array($this->ns[$m[1]], $this->used_ns) ? array_merge($this->used_ns, array($this->ns[$m[1]])) : $this->used_ns; + return $v; + } + if (preg_match('/^(.*[\/\#])([a-z\_][a-z0-9\-\_]*)$/i', $v, $m)) { + return $this->getPrefix($m[1]) . ':' . $m[2]; + } + return 0; + } + + /* */ + + function getSerializedTriples($triples, $raw = 0) { + $index = ARC2::getSimpleIndex($triples, 0); + return $this->getSerializedIndex($index, $raw); + } + + function getSerializedIndex($index, $raw = 0) { + return ''; + } + + /* */ + +} diff --git a/arc2-2.2.4/serializers/ARC2_RDFXMLSerializer.php b/arc2-2.2.4/serializers/ARC2_RDFXMLSerializer.php new file mode 100755 index 0000000..d960292 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_RDFXMLSerializer.php @@ -0,0 +1,198 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFSerializer'); + +class ARC2_RDFXMLSerializer extends ARC2_RDFSerializer { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->content_header = 'application/rdf+xml'; + $this->pp_containers = $this->v('serializer_prettyprint_containers', 0, $this->a); + $this->default_ns = $this->v('serializer_default_ns', '', $this->a); + $this->type_nodes = $this->v('serializer_type_nodes', 0, $this->a); + } + + /* */ + + function getTerm($v, $type) { + if (!is_array($v)) {/* uri or bnode */ + if (preg_match('/^\_\:(.*)$/', $v, $m)) { + return ' rdf:nodeID="' . $m[1] . '"'; + } + if ($type == 's') { + return ' rdf:about="' . htmlspecialchars($v) . '"'; + } + if ($type == 'p') { + $pn = $this->getPName($v); + return $pn ? $pn : 0; + } + if ($type == 'o') { + $v = $this->expandPName($v); + if (!preg_match('/^[a-z0-9]{2,}\:[^\s]+$/is', $v)) return $this->getTerm(array('value' => $v, 'type' => 'literal'), $type); + return ' rdf:resource="' . htmlspecialchars($v) . '"'; + } + if ($type == 'datatype') { + $v = $this->expandPName($v); + return ' rdf:datatype="' . htmlspecialchars($v) . '"'; + } + if ($type == 'lang') { + return ' xml:lang="' . htmlspecialchars($v) . '"'; + } + } + if ($this->v('type', '', $v) != 'literal') { + return $this->getTerm($v['value'], 'o'); + } + /* literal */ + $dt = isset($v['datatype']) ? $v['datatype'] : ''; + $lang = isset($v['lang']) ? $v['lang'] : ''; + if ($dt == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral') { + return ' rdf:parseType="Literal">' . $v['value']; + } + elseif ($dt) { + return $this->getTerm($dt, 'datatype') . '>' . htmlspecialchars($v['value']); + } + elseif ($lang) { + return $this->getTerm($lang, 'lang') . '>' . htmlspecialchars($v['value']); + } + return '>' . htmlspecialchars($this->v('value', '', $v)); + } + + function getPName($v, $connector = ':') { + if ($this->default_ns && (strpos($v, $this->default_ns) === 0)) { + $pname = substr($v, strlen($this->default_ns)); + if (!preg_match('/\//', $pname)) return $pname; + } + return parent::getPName($v, $connector); + } + + function getHead() { + $r = ''; + $nl = "\n"; + $r .= ''; + $r .= $nl . 'used_ns as $v) { + $r .= $first_ns ? ' ' : $nl . ' '; + foreach ($this->ns as $prefix => $ns) { + if ($ns != $v) continue; + $r .= 'xmlns:' . $prefix . '="' .$v. '"'; + break; + } + $first_ns = 0; + } + if ($this->default_ns) { + $r .= $first_ns ? ' ' : $nl . ' '; + $r .= 'xmlns="' . $this->default_ns . '"'; + } + $r .= '>'; + return $r; + } + + function getFooter() { + $r = ''; + $nl = "\n"; + $r .= $nl . $nl . ''; + return $r; + } + + function getSerializedIndex($index, $raw = 0) { + $r = ''; + $nl = "\n"; + foreach ($index as $raw_s => $ps) { + $r .= $r ? $nl . $nl : ''; + $s = $this->getTerm($raw_s, 's'); + $tag = 'rdf:Description'; + list($tag, $ps) = $this->getNodeTag($ps); + $sub_ps = 0; + /* pretty containers */ + if ($this->pp_containers && ($ctag = $this->getContainerTag($ps))) { + $tag = 'rdf:' . $ctag; + list($ps, $sub_ps) = $this->splitContainerEntries($ps); + } + $r .= ' <' . $tag . '' .$s . '>'; + $first_p = 1; + foreach ($ps as $p => $os) { + if (!$os) continue; + $p = $this->getTerm($p, 'p'); + if ($p) { + $r .= $nl . str_pad('', 4); + $first_o = 1; + if (!is_array($os)) {/* single literal o */ + $os = array(array('value' => $os, 'type' => 'literal')); + } + foreach ($os as $o) { + $o = $this->getTerm($o, 'o'); + $r .= $first_o ? '' : $nl . ' '; + $r .= '<' . $p; + $r .= $o; + $r .= preg_match('/\>/', $o) ? '' : '/>'; + $first_o = 0; + } + $first_p = 0; + } + } + $r .= $r ? $nl . ' ' : ''; + if ($sub_ps) $r .= $nl . $nl . $this->getSerializedIndex(array($raw_s => $sub_ps), 1); + } + if ($raw) { + return $r; + } + return $this->getHead() . $nl . $nl . $r . $this->getFooter(); + } + + function getNodeTag($ps) { + if (!$this->type_nodes) return array('rdf:Description', $ps); + $rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $types = $this->v($rdf . 'type', array(), $ps); + if (!$types) return array('rdf:Description', $ps); + $type = array_shift($types); + $ps[$rdf . 'type'] = $types; + if (!is_array($type)) $type = array('value' => $type); + return array($this->getPName($type['value']), $ps); + } + + /* */ + + function getContainerTag($ps) { + $rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + if (!isset($ps[$rdf . 'type'])) return ''; + $types = $ps[$rdf . 'type']; + foreach ($types as $type) { + if (!in_array($type['value'], array($rdf . 'Bag', $rdf . 'Seq', $rdf . 'Alt'))) return ''; + return str_replace($rdf, '', $type['value']); + } + } + + function splitContainerEntries($ps) { + $rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $items = array(); + $rest = array(); + foreach ($ps as $p => $os) { + $p_short = str_replace($rdf, '', $p); + if ($p_short === 'type') continue; + if (preg_match('/^\_([0-9]+)$/', $p_short, $m)) { + $items = array_merge($items, $os); + } + else { + $rest[$p] = $os; + } + } + if ($items) return array(array($rdf . 'li' => $items), $rest); + return array($rest, 0); + } + + /* */ +} diff --git a/arc2-2.2.4/serializers/ARC2_RSS10Serializer.php b/arc2-2.2.4/serializers/ARC2_RSS10Serializer.php new file mode 100755 index 0000000..6575b46 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_RSS10Serializer.php @@ -0,0 +1,30 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFXMLSerializer'); + +class ARC2_RSS10Serializer extends ARC2_RDFXMLSerializer { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->content_header = 'application/rss+xml'; + $this->default_ns = 'http://purl.org/rss/1.0/'; + $this->type_nodes = true; + } + + /* */ + +} diff --git a/arc2-2.2.4/serializers/ARC2_TurtleSerializer.php b/arc2-2.2.4/serializers/ARC2_TurtleSerializer.php new file mode 100755 index 0000000..f9420e4 --- /dev/null +++ b/arc2-2.2.4/serializers/ARC2_TurtleSerializer.php @@ -0,0 +1,121 @@ + + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('RDFSerializer'); + +class ARC2_TurtleSerializer extends ARC2_RDFSerializer { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->content_header = 'application/x-turtle'; + } + + /* */ + + function getTerm($v, $term = '', $qualifier = '') { + if (!is_array($v)) { + if (preg_match('/^\_\:/', $v)) { + return $v; + } + if (($term === 'p') && ($pn = $this->getPName($v))) { + return $pn; + } + if ( + ($term === 'o') && + in_array($qualifier, array('rdf:type', 'rdfs:domain', 'rdfs:range', 'rdfs:subClassOf')) && + ($pn = $this->getPName($v)) + ) { + return $pn; + } + if (preg_match('/^[a-z0-9]+\:[^\s]*$/is' . ($this->has_pcre_unicode ? 'u' : ''), $v)) { + return '<' .$v. '>'; + } + return $this->getTerm(array('type' => 'literal', 'value' => $v), $term, $qualifier); + } + if (!isset($v['type']) || ($v['type'] != 'literal')) { + return $this->getTerm($v['value'], $term, $qualifier); + } + /* literal */ + $quot = '"'; + if (preg_match('/\"/', $v['value'])) { + $quot = "'"; + if (preg_match('/\'/', $v['value']) || preg_match('/[\x0d\x0a]/', $v['value'])) { + $quot = '"""'; + if (preg_match('/\"\"\"/', $v['value']) || preg_match('/\"$/', $v['value']) || preg_match('/^\"/', $v['value'])) { + $quot = "'''"; + $v['value'] = preg_replace("/'$/", "' ", $v['value']); + $v['value'] = preg_replace("/^'/", " '", $v['value']); + $v['value'] = str_replace("'''", '\\\'\\\'\\\'', $v['value']); + } + } + } + if ((strlen($quot) == 1) && preg_match('/[\x0d\x0a]/', $v['value'])) { + $quot = $quot . $quot . $quot; + } + $suffix = isset($v['lang']) && $v['lang'] ? '@' . $v['lang'] : ''; + $suffix = isset($v['datatype']) && $v['datatype'] ? '^^' . $this->getTerm($v['datatype'], 'dt') : $suffix; + return $quot . $v['value'] . $quot . $suffix; + } + + function getHead() { + $r = ''; + $nl = "\n"; + foreach ($this->used_ns as $v) { + $r .= $r ? $nl : ''; + foreach ($this->ns as $prefix => $ns) { + if ($ns != $v) continue; + $r .= '@prefix ' . $prefix . ': <' .$v. '> .'; + break; + } + } + return $r; + } + + function getSerializedIndex($index, $raw = 0) { + $r = ''; + $nl = "\n"; + foreach ($index as $s => $ps) { + $r .= $r ? ' .' . $nl . $nl : ''; + $s = $this->getTerm($s, 's'); + $r .= $s; + $first_p = 1; + foreach ($ps as $p => $os) { + if (!$os) continue; + $p = $this->getTerm($p, 'p'); + $r .= $first_p ? ' ' : ' ;' . $nl . str_pad('', strlen($s) + 1); + $r .= $p; + $first_o = 1; + if (!is_array($os)) {/* single literal o */ + $os = array(array('value' => $os, 'type' => 'literal')); + } + foreach ($os as $o) { + $r .= $first_o ? ' ' : ' ,' . $nl . str_pad('', strlen($s) + strlen($p) + 2); + $o = $this->getTerm($o, 'o', $p); + $r .= $o; + $first_o = 0; + } + $first_p = 0; + } + } + $r .= $r ? ' .' : ''; + if ($raw) { + return $r; + } + return $r ? $this->getHead() . $nl . $nl . $r : ''; + } + + /* */ + +} diff --git a/arc2-2.2.4/sparqlscript/ARC2_SPARQLScriptParser.php b/arc2-2.2.4/sparqlscript/ARC2_SPARQLScriptParser.php new file mode 100755 index 0000000..7dc3689 --- /dev/null +++ b/arc2-2.2.4/sparqlscript/ARC2_SPARQLScriptParser.php @@ -0,0 +1,280 @@ +setDefaultPrefixes(); + $this->base = $src ? $this->calcBase($src) : ARC2::getScriptURI(); + $this->blocks = array(); + $this->r = array('base' => '', 'vars' => array(), 'prefixes' => $this->prefixes); + do { + $proceed = 0; + if ((list($r, $v) = $this->xScriptBlock($v)) && $r) { + $this->blocks[] = $r; + $proceed = 1; + } + $this->unparsed_code = trim($v); + } while ($proceed); + if (trim($this->unparsed_code) && !$this->getErrors()) { + $rest = preg_replace('/[\x0a|\x0d]/i', ' ', substr($this->unparsed_code, 0, 30)); + $msg = trim($rest) ? 'Could not properly handle "' . $rest . '"' : 'Syntax Error'; + $this->addError($msg); + } + } + + function getScriptBlocks() { + return $this->v('blocks', array()); + } + + /* */ + + function xScriptBlock($v) { + /* comment removal */ + while (preg_match('/^\s*(\#[^\xd\xa]*)(.*)$/si', $v, $m)) $v = $m[2]; + /* BaseDecl */ + if ((list($sub_r, $v) = $this->xBaseDecl($v)) && $sub_r) { + $this->base = $sub_r; + } + /* PrefixDecl */ + while ((list($r, $v) = $this->xPrefixDecl($v)) && $r) { + $this->prefixes[$r['prefix']] = $r['uri']; + } + /* EndpointDecl */ + if ((list($r, $v) = $this->xEndpointDecl($v)) && $r) { + return array($r, $v); + } + /* Return */ + if ((list($r, $v) = $this->xReturn($v)) && $r) { + return array($r, $v); + } + /* Assignment */ + if ((list($r, $v) = $this->xAssignment($v)) && $r) { + return array($r, $v); + } + /* IFBlock */ + if ((list($r, $v) = $this->xIFBlock($v)) && $r) { + return array($r, $v); + } + /* FORBlock */ + if ((list($r, $v) = $this->xFORBlock($v)) && $r) { + return array($r, $v); + } + /* String */ + if ((list($r, $v) = $this->xString($v)) && $r) { + return array($r, $v); + } + /* FunctionCall */ + if ((list($r, $v) = $this->xFunctionCall($v)) && $r) { + return array($r, ltrim($v, ';')); + } + /* Query */ + $prev_r = $this->r; + $this->r = array('base' => '', 'vars' => array(), 'prefixes' => $this->prefixes); + if ((list($r, $rest) = $this->xQuery($v)) && $r) { + $q = $rest ? trim(substr($v, 0, -strlen($rest))) : trim($v); + $v = $rest; + $r = array_merge($this->r, array( + 'type' => 'query', + 'query_type' => $r['type'], + 'query' => $q, + //'prefixes' => $this->prefixes, + 'base' => $this->base, + //'infos' => $r + )); + return array($r, $v); + } + else { + $this->r = $prev_r; + } + return array(0, $v); + } + + function xBlockSet($v) { + if (!$r = $this->x("\{", $v)) return array(0, $v); + $blocks = array(); + $sub_v = $r[1]; + while ((list($sub_r, $sub_v) = $this->xScriptBlock($sub_v)) && $sub_r) { + $blocks[] = $sub_r; + } + if (!$sub_r = $this->x("\}", $sub_v)) return array(0, $v); + $sub_v = $sub_r[1]; + return array(array('type' => 'block_set', 'blocks' => $blocks), $sub_v); + } + + /* s2 */ + + function xEndpointDecl($v) { + if ($r = $this->x("ENDPOINT\s+", $v)) { + if ((list($r, $sub_v) = $this->xIRI_REF($r[1])) && $r) { + $r = $this->calcURI($r, $this->base); + if ($sub_r = $this->x('\.', $sub_v)) { + $sub_v = $sub_r[1]; + } + return array( + array('type' => 'endpoint_decl', 'endpoint' => $r), + $sub_v + ); + } + } + return array(0, $v); + } + + /* s3 */ + + function xAssignment($v) { + /* Var */ + list($r, $sub_v) = $this->xVar($v); + if (!$r) return array(0, $v); + $var = $r; + /* := | = */ + if (!$sub_r = $this->x("\:?\=", $sub_v)) return array(0, $v); + $sub_v = $sub_r[1]; + /* try String */ + list($r, $sub_v) = $this->xString($sub_v); + if ($r) return array(array('type' => 'assignment', 'var' => $var, 'sub_type' => 'string', 'string' => $r), ltrim($sub_v, '; ')); + /* try VarMerge */ + list($r, $sub_v) = $this->xVarMerge($sub_v); + if ($r) return array(array('type' => 'assignment', 'var' => $var, 'sub_type' => 'var_merge', 'var2' => $r[0], 'var3' => $r[1]), ltrim($sub_v, '; ')); + /* try Var */ + list($r, $sub_v) = $this->xVar($sub_v); + if ($r) return array(array('type' => 'assignment', 'var' => $var, 'sub_type' => 'var', 'var2' => $r), ltrim($sub_v, '; ')); + /* try function */ + list($r, $sub_v) = $this->xFunctionCall($sub_v); + if ($r) return array(array('type' => 'assignment', 'var' => $var, 'sub_type' => 'function_call', 'function_call' => $r), ltrim($sub_v, '; ')); + /* try Placeholder */ + list($r, $sub_v) = $this->xPlaceholder($sub_v); + if ($r) return array(array('type' => 'assignment', 'var' => $var, 'sub_type' => 'placeholder', 'placeholder' => $r), ltrim($sub_v, '; ')); + /* try query */ + $prev_r = $this->r; + $this->r = array('base' => '', 'vars' => array(), 'prefixes' => $this->prefixes); + list($r, $rest) = $this->xQuery($sub_v); + if (!$r) { + $this->r = $prev_r; + return array(0, $v); + } + else { + $q = $rest ? trim(substr($sub_v, 0, -strlen($rest))) : trim($sub_v); + return array( + array( + 'type' => 'assignment', + 'var' => $var, + 'sub_type' => 'query', + 'query' => array_merge($this->r, array( + 'type' => 'query', + 'query_type' => $r['type'], + 'query' => $q, + 'base' => $this->base, + )), + ), + ltrim($rest, '; ') + ); + } + } + + function xReturn($v) { + if ($r = $this->x("return\s+", $v)) { + /* fake assignment which accepts same right-hand values */ + $sub_v = '$__return_value__ := ' . $r[1]; + if ((list($r, $sub_v) = $this->xAssignment($sub_v)) && $r) { + $r['type'] = 'return'; + return array($r, $sub_v); + } + } + return array(0, $v); + } + + /* s4 'IF' BrackettedExpression '{' Script '}' ( 'ELSE' '{' Script '}')? */ + + function xIFBlock($v) { + if ($r = $this->x("IF\s*", $v)) { + if ((list($sub_r, $sub_v) = $this->xBrackettedExpression($r[1])) && $sub_r) { + $cond = $sub_r; + if ((list($sub_r, $sub_v) = $this->xBlockSet($sub_v)) && $sub_r) { + $blocks = $sub_r['blocks']; + /* else */ + $else_blocks = array(); + $rest = $sub_v; + if ($sub_r = $this->x("ELSE\s*", $sub_v)) { + if ((list($sub_r, $sub_v) = $this->xBlockSet($sub_r[1])) && $sub_r) { + $else_blocks = $sub_r['blocks']; + } + else { + $sub_v = $rest; + } + } + return array( + array( + 'type' => 'ifblock', + 'condition' => $cond, + 'blocks' => $blocks, + 'else_blocks' => $else_blocks, + ), + $sub_v + ); + } + } + } + return array(0, $v); + } + + /* s5 'FOR' '(' Var 'IN' Var ')' '{' Script '}' */ + + function xFORBlock($v) { + if ($r = $this->x("FOR\s*\(\s*[\$\?]([^\s]+)\s+IN\s+[\$\?]([^\s]+)\s*\)", $v)) {/* @@todo split into sub-patterns? */ + $iterator = $r[1]; + $set_var = $r[2]; + $sub_v = $r[3]; + if ((list($sub_r, $sub_v) = $this->xBlockSet($sub_v)) && $sub_r) { + return array( + array( + 'type' => 'forblock', + 'set' => $set_var, + 'iterator' => $iterator, + 'blocks' => $sub_r['blocks'] + ), + $sub_v + ); + } + } + return array(0, $v); + } + + /* s6 Var '+' Var */ + + function xVarMerge($v) { + if ((list($sub_r, $sub_v) = $this->xVar($v)) && $sub_r) { + $var1 = $sub_r; + if ($sub_r = $this->x("\+", $sub_v)) { + $sub_v = $sub_r[1]; + if ((list($sub_r, $sub_v) = $this->xVar($sub_v)) && $sub_r) { + return array( + array($var1, $sub_r), + $sub_v + ); + } + } + } + return array(0, $v); + } + +} diff --git a/arc2-2.2.4/sparqlscript/ARC2_SPARQLScriptProcessor.php b/arc2-2.2.4/sparqlscript/ARC2_SPARQLScriptProcessor.php new file mode 100755 index 0000000..e9dcfc4 --- /dev/null +++ b/arc2-2.2.4/sparqlscript/ARC2_SPARQLScriptProcessor.php @@ -0,0 +1,592 @@ + + * @license http://arc.semsol.org/license + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_SPARQLScriptProcessor extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->max_operations = $this->v('sparqlscript_max_operations', 0, $this->a); + $this->max_queries = $this->v('sparqlscript_max_queries', 0, $this->a); + $this->return = 0; + $this->script_hash = ''; + $this->env = array( + 'endpoint' => '', + 'vars' => array(), + 'output' => '', + 'operation_count' => 0, + 'query_count' => 0, + 'query_log' => array() + ); + } + + function reset() { + $this->__init(); + } + + /* */ + + function processScript($s) { + $this->script_hash = abs(crc32($s)); + $parser = $this->getParser(); + $parser->parse($s); + $blocks = $parser->getScriptBlocks(); + if ($parser->getErrors()) return 0; + foreach ($blocks as $block) { + $this->processBlock($block); + if ($this->return) return 0; + if ($this->getErrors()) return 0; + } + } + + function getResult() { + if ($this->return) { + return $this->getVarValue('__return_value__'); + } + else { + return $this->env['output']; + } + } + + /* */ + + function getParser() { + ARC2::inc('SPARQLScriptParser'); + return new ARC2_SPARQLScriptParser($this->a, $this); + } + + /* */ + + function setVar($name, $val, $type = 'literal', $meta = '') { + /* types: literal, var, rows, bool, doc, http_response, undefined, ? */ + $this->env['vars'][$name] = array( + 'value_type' => $type, + 'value' => $val, + 'meta' => $meta ? $meta : array() + ); + } + + function getVar($name) { + return isset($this->env['vars'][$name]) ? $this->env['vars'][$name] : ''; + } + + function getVarValue($name) { + return ($v = $this->getVar($name)) ? (isset($v['value']) ? $v['value'] : $v ) : ''; + } + + /* */ + + function replacePlaceholders($val, $context = '', $return_string = 1, $loop = 0) { + do { + $old_val = $val; + if (preg_match_all('/(\{(?:[^{}]+|(?R))*\})/', $val, $m)) { + foreach ($m[1] as $match) { + if (strpos($val, '$' . $match) === false) {/* just some container brackets, recurse */ + $val = str_replace($match, '{' . $this->replacePlaceholders(substr($match, 1, -1), $context, $return_string, $loop + 1) . '}', $val); + } + else { + $ph = substr($match, 1, -1); + $sub_val = $this->getPlaceholderValue($ph); + if (is_array($sub_val)) { + $sub_val = $this->getArraySerialization($sub_val, $context); + } + $val = str_replace('${' . $ph . '}', $sub_val, $val); + } + } + } + } while (($old_val != $val) && ($loop < 10)); + return $val; + } + + function getPlaceholderValue($ph) { + /* simple vars */ + if (isset($this->env['vars'][$ph])) { + return $this->v('value', $this->env['vars'][$ph], $this->env['vars'][$ph]); + } + /* GET/POST */ + if (preg_match('/^(GET|POST)\.([^\.]+)(.*)$/', $ph, $m)) { + $vals = strtoupper($m[1]) == 'GET' ? $_GET : $POST; + $r = isset($vals[$m[2]]) ? $vals[$m[2]] : ''; + return $m[3] ? $this->getPropertyValue(array('value' => $r, 'value_type' => '?'), ltrim($m[3], '.')) : $r; + } + /* NOW */ + if (preg_match('/^NOW(.*)$/', $ph, $m)) { + $rest = $m[1]; + /* may have sub-phs */ + $rest = $this->replacePlaceholders($rest); + $r_struct = array( + 'y' => date('Y'), + 'mo' => date('m'), + 'd' => date('d'), + 'h' => date('H'), + 'mi' => date('i'), + 's' => date('s') + ); + if (preg_match('/(\+|\-)\s*([0-9]+)(y|mo|d|h|mi|s)[a-z]*(.*)/is', trim($rest), $m2)) { + eval('$r_struct[$m2[3]] ' . $m2[1] . '= (int)' . $m2[2] . ';'); + $rest = $m2[4]; + } + $uts = mktime($r_struct['h'], $r_struct['mi'], $r_struct['s'], $r_struct['mo'], $r_struct['d'], $r_struct['y']); + $uts -= date('Z', $uts); /* timezone offset */ + $r = date('Y-m-d\TH:i:s\Z', $uts); + if (preg_match('/^\.(.+)$/', $rest, $m)) { + return $this->getPropertyValue(array('value' => $r), $m[1]); + } + return $r; + } + /* property */ + if (preg_match('/^([^\.]+)\.(.+)$/', $ph, $m)) { + list($var, $path) = array($m[1], $m[2]); + if (isset($this->env['vars'][$var])) { + return $this->getPropertyValue($this->env['vars'][$var], $path); + } + } + return ''; + } + + function getPropertyValue($obj, $path) { + $val = isset($obj['value']) ? $obj['value'] : $obj; + $path = $this->replacePlaceholders($path, 'property_value', 0); + /* reserved */ + if ($path == 'size') { + if ($obj['value_type'] == 'rows') return count($val); + if ($obj['value_type'] == 'literal') return strlen($val); + } + if (preg_match('/^replace\([\'\"](\/.*\/[a-z]*)[\'\"],\s*[\'\"](.*)[\'\"]\)$/is', $path, $m)) { + return @preg_replace($m[1], str_replace('$', '\\', $m[2]), $val); + } + if (preg_match('/^match\([\'\"](\/.*\/[a-z]*)[\'\"]\)$/is', $path, $m)) { + return @preg_match($m[1], $val, $m) ? $m : ''; + } + if (preg_match('/^urlencode\([\'\"]?(get|post|.*)[\'\"]?\)$/is', $path, $m)) { + return (strtolower($m[1]) == 'post') ? rawurlencode($val) : urlencode($val); + } + if (preg_match('/^toDataURI\([^\)]*\)$/is', $path, $m)) { + return 'data:text/plain;charset=utf-8,' . rawurlencode($val); + } + if (preg_match('/^fromDataURI\([^\)]*\)$/is', $path, $m)) { + return rawurldecode(str_replace('data:text/plain;charset=utf-8,', '', $val)); + } + if (preg_match('/^toPrettyDate\([^\)]*\)$/is', $path, $m)) { + $uts = strtotime(preg_replace('/(T|\+00\:00)/', ' ', $val)); + return date('D j M H:i', $uts); + } + if (preg_match('/^render\(([^\)]*)\)$/is', $path, $m)) { + $src_format = trim($m[1], '"\''); + return $this->render($val, $src_format); + } + /* struct */ + if (is_array($val)) { + if (isset($val[$path])) return $val[$path]; + $exp_path = $this->expandPName($path); + if (isset($val[$exp_path])) return $val[$exp_path]; + if (preg_match('/^([^\.]+)\.(.+)$/', $path, $m)) { + list($var, $path) = array($m[1], $m[2]); + if (isset($val[$var])) { + return $this->getPropertyValue(array('value' => $val[$var]), $path); + } + /* qname */ + $exp_var = $this->expandPName($var); + if (isset($val[$exp_var])) { + return $this->getPropertyValue(array('value' => $val[$exp_var]), $path); + } + return ''; + } + } + /* meta */ + if (preg_match('/^\_/', $path) && isset($obj['meta']) && isset($obj['meta'][substr($path, 1)])) { + return $obj['meta'][substr($path, 1)]; + } + return ''; + } + + function render($val, $src_format = '') { + if ($src_format) { + $mthd = 'render' . $this->camelCase($src_format); + if (method_exists($this, $mthd)) { + return $this->$mthd($val); + } + else { + return 'No rendering method found for "' . $src_format. '"'; + } + } + /* try RDF */ + return $this->getArraySerialization($val); + } + + function renderObjects($os) { + $r = ''; + foreach ($os as $o) { + $r .= $r ? ', ' : ''; + $r .= $o['value']; + } + return $r; + } + + /* */ + + function getArraySerialization($v, $context) { + $v_type = ARC2::getStructType($v);/* string|array|triples|index */ + $pf = ARC2::getPreferredFormat(); + /* string */ + if ($v_type == 'string') return $v; + /* simple array (e.g. from SELECT) */ + if ($v_type == 'array') { + return join(', ', $v); + $m = method_exists($this, 'toLegacy' . $pf) ? 'toLegacy' . $pf : 'toLegacyXML'; + } + /* rdf */ + if (($v_type == 'triples') || ($v_type == 'index')) { + $m = method_exists($this, 'to' . $pf) ? 'to' . $pf : ($context == 'query' ? 'toNTriples' : 'toRDFXML'); + } + /* else */ + return $this->$m($v); + } + + /* */ + + function processBlock($block) { + if ($this->max_operations && ($this->env['operation_count'] >= $this->max_operations)) return $this->addError('Number of ' . $this->max_operations . ' allowed operations exceeded.'); + if ($this->return) return 0; + $this->env['operation_count']++; + $type = $block['type']; + $m = 'process' . $this->camelCase($type) . 'Block'; + if (method_exists($this, $m)) { + return $this->$m($block); + } + return $this->addError('Unsupported block type "' . $type . '"'); + } + + /* */ + + function processEndpointDeclBlock($block) { + $this->env['endpoint'] = $block['endpoint']; + return $this->env; + } + + /* */ + + function processQueryBlock($block) { + if ($this->max_queries && ($this->env['query_count'] >= $this->max_queries)) return $this->addError('Number of ' . $this->max_queries . ' allowed queries exceeded.'); + $this->env['query_count']++; + $ep_uri = $this->replacePlaceholders($this->env['endpoint'], 'endpoint'); + /* q */ + $prologue = 'BASE <' . $block['base']. '>'; + $q = $this->replacePlaceholders($block['query'], 'query'); + /* prefixes */ + $ns = isset($this->a['ns']) ? array_merge($this->a['ns'], $block['prefixes']) : $block['prefixes']; + $q = $prologue . "\n" . $this->completeQuery($q, $ns); + $this->env['query_log'][] = '(' . $ep_uri . ') ' . $q; + if ($store = $this->getStore($ep_uri)) { + $sub_r = $this->v('is_remote', '', $store) ? $store->query($q, '', $ep_uri) : $store->query($q); + /* ignore socket errors */ + if (($errs = $this->getErrors()) && preg_match('/socket/', $errs[0])) { + $this->warnings[] = $errs[0]; + $this->errors = array(); + $sub_r = array(); + } + return $sub_r; + } + else { + return $this->addError("no store (" . $ep_uri . ")"); + } + } + + function getStore($ep_uri) { + /* local store */ + if ((!$ep_uri || $ep_uri == ARC2::getScriptURI()) && ($this->v('sparqlscript_default_endpoint', '', $this->a) == 'local')) { + if (!isset($this->local_store)) $this->local_store = ARC2::getStore($this->a);/* @@todo error checking */ + return $this->local_store; + } + elseif ($ep_uri) { + ARC2::inc('RemoteStore'); + $conf = array_merge($this->a, array('remote_store_endpoint' => $ep_uri, 'reader_timeout' => 10)); + return new ARC2_RemoteStore($conf, $this); + } + return 0; + } + + /* */ + + function processAssignmentBlock($block) { + $sub_type = $block['sub_type']; + $m = 'process' . $this->camelCase($sub_type) . 'AssignmentBlock'; + if (!method_exists($this, $m)) return $this->addError('Unknown method "' . $m . '"'); + return $this->$m($block); + } + + function processQueryAssignmentBlock($block) { + $qr = $this->processQueryBlock($block['query']); + if ($this->getErrors() || !isset($qr['query_type'])) return 0; + $qt = $qr['query_type']; + $vts = array('ask' => 'bool', 'select' => 'rows', 'desribe' => 'doc', 'construct' => 'doc'); + $r = array( + 'value_type' => isset($vts[$qt]) ? $vts[$qt] : $qt . ' result', + 'value' => ($qt == 'select') ? $this->v('rows', array(), $qr['result']) : $qr['result'], + ); + $this->env['vars'][$block['var']['value']] = $r; + } + + function processStringAssignmentBlock($block) { + $r = array('value_type' => 'literal', 'value' => $this->replacePlaceholders($block['string']['value'])); + $this->env['vars'][$block['var']['value']] = $r; + } + + function processVarAssignmentBlock($block) { + if (isset($this->env['vars'][$block['var2']['value']])) { + $this->env['vars'][$block['var']['value']] = $this->env['vars'][$block['var2']['value']]; + } + else { + $this->env['vars'][$block['var']['value']] = array('value_type' => 'undefined', 'value' => ''); + } + } + + function processPlaceholderAssignmentBlock($block) { + $ph_val = $this->getPlaceholderValue($block['placeholder']['value']); + $this->env['vars'][$block['var']['value']] = array('value_type' => 'undefined', 'value' => $ph_val); + } + + function processVarMergeAssignmentBlock($block) { + $val1 = isset($this->env['vars'][$block['var2']['value']]) ? $this->env['vars'][$block['var2']['value']] : array('value_type' => 'undefined', 'value' => ''); + $val2 = isset($this->env['vars'][$block['var3']['value']]) ? $this->env['vars'][$block['var3']['value']] : array('value_type' => 'undefined', 'value' => ''); + if (is_array($val1) && is_array($val2)) { + $this->env['vars'][$block['var']['value']] = array('value_type' => $val2['value_type'], 'value' => array_merge($val1['value'], $val2['value'])); + } + elseif (is_numeric($val1) && is_numeric($val2)) { + $this->env['vars'][$block['var']['value']] = $val1 + $val2; + } + } + + function processFunctionCallAssignmentBlock($block) { + $sub_r = $this->processFunctionCallBlock($block['function_call']); + if ($this->getErrors()) return 0; + $this->env['vars'][$block['var']['value']] = $sub_r; + } + + /* */ + + function processReturnBlock($block) { + $sub_type = $block['sub_type']; + $m = 'process' . $this->camelCase($sub_type) . 'AssignmentBlock'; + if (!method_exists($this, $m)) return $this->addError('Unknown method "' . $m . '"'); + $sub_r = $this->$m($block); + $this->return = 1; + return $sub_r; + } + + /* */ + + function processIfblockBlock($block) { + if ($this->testCondition($block['condition'])) { + $blocks = $block['blocks']; + } + else { + $blocks = $block['else_blocks']; + } + foreach ($blocks as $block) { + $sub_r = $this->processBlock($block); + if ($this->getErrors()) return 0; + } + } + + function testCondition($cond) { + $m = 'test' . $this->camelCase($cond['type']) . 'Condition'; + if (!method_exists($this, $m)) return $this->addError('Unknown method "' . $m . '"'); + return $this->$m($cond); + } + + function testVarCondition($cond) { + $r = 0; + $vn = $cond['value']; + if (isset($this->env['vars'][$vn])) $r = $this->env['vars'][$vn]['value']; + $op = $this->v('operator', '', $cond); + if ($op == '!') $r = !$r; + return $r ? true : false; + } + + function testPlaceholderCondition($cond) { + $val = $this->getPlaceholderValue($cond['value']); + $r = $val ? true : false; + $op = $this->v('operator', '', $cond); + if ($op == '!') $r = !$r; + return $r; + } + + function testExpressionCondition($cond) { + $m = 'test' . $this->camelCase($cond['sub_type']) . 'ExpressionCondition'; + if (!method_exists($this, $m)) return $this->addError('Unknown method "' . $m . '"'); + return $this->$m($cond); + } + + function testRelationalExpressionCondition($cond) { + $op = $cond['operator']; + if ($op == '=') $op = '=='; + $val1 = $this->getPatternValue($cond['patterns'][0]); + $val2 = $this->getPatternValue($cond['patterns'][1]); + eval('$result = ($val1 ' . $op . ' $val2) ? 1 : 0;'); + return $result; + } + + function testAndExpressionCondition($cond) { + foreach ($cond['patterns'] as $pattern) { + if (!$this->testCondition($pattern)) return false; + } + return true; + } + + function getPatternValue($pattern) { + $m = 'get' . $this->camelCase($pattern['type']) . 'PatternValue'; + if (!method_exists($this, $m)) return ''; + return $this->$m($pattern); + } + + function getLiteralPatternValue($pattern) { + return $pattern['value']; + } + + function getPlaceholderPatternValue($pattern) { + return $this->getPlaceholderValue($pattern['value']); + } + + /* */ + + function processForblockBlock($block) { + $set = $this->v($block['set'], array('value' => array()), $this->env['vars']); + $entries = isset($set['value']) ? $set['value'] : $set; + $iterator = $block['iterator']; + $blocks = $block['blocks']; + if (!is_array($entries)) return 0; + $rc = count($entries); + foreach ($entries as $i => $entry) { + $val_type = $this->v('value_type', 'set', $set) . ' entry'; + $this->env['vars'][$iterator] = array( + 'value' => $entry, + 'value_type' => $val_type, + 'meta' => array( + 'pos' => $i, + 'odd_even' => ($i % 2) ? 'even' : 'odd' + ) + ); + foreach ($blocks as $block) { + $this->processBlock($block); + if ($this->getErrors()) return 0; + } + } + } + + /* */ + + function processLiteralBlock($block) { + $this->env['output'] .= $this->replacePlaceholders($block['value'], 'output'); + } + + /* */ + + function processFunctionCallBlock($block) { + $uri = $this->replacePlaceholders($block['uri'], 'function_call'); + /* built-ins */ + if (strpos($uri, $this->a['ns']['sps']) === 0) { + return $this->processBuiltinFunctionCallBlock($block); + } + /* remote functions */ + } + + function processBuiltinFunctionCallBlock($block) { + $fnc_uri = $this->replacePlaceholders($block['uri'], 'function_call'); + $fnc_name = substr($fnc_uri, strlen($this->a['ns']['sps'])); + if (preg_match('/^(get|post)$/i', $fnc_name, $m)) { + return $this->processHTTPCall($block, strtoupper($m[1])); + } + if ($fnc_name == 'eval') { + return $this->processEvalCall($block); + } + } + + function processEvalCall($block) { + if (!$block['args']) return 0; + $arg = $block['args'][0]; + $script = ''; + if ($arg['type'] == 'placeholder') $script = $this->getPlaceholderValue($arg['value']); + if ($arg['type'] == 'literal') $script = $arg['value']; + if ($arg['type'] == 'var') $script = $this->getVarValue($arg['value']); + //echo "\n" . $script . $arg['type']; + $this->processScript($script); + } + + function processHTTPCall($block, $mthd = 'GET') { + ARC2::inc('Reader'); + $reader = new ARC2_Reader($this->a, $this); + $url = $this->replacePlaceholders($block['args'][0]['value'], 'function_call'); + if ($mthd != 'GET') { + $reader->setHTTPMethod($mthd); + $reader->setCustomHeaders("Content-Type: application/x-www-form-urlencoded"); + } + $to = $this->v('remote_call_timeout', 0, $this->a); + $reader->activate($url, '', 0, $to); + $format = $reader->getFormat(); + $resp = ''; + while ($d = $reader->readStream()) { + $resp .= $d; + } + $reader->closeStream(); + unset($this->reader); + return array('value_type' => 'http_response', 'value' => $resp); + } + + /* */ + + function extractVars($pattern, $input = '') { + $vars = array(); + /* replace PHs, track ()s */ + $regex = $pattern; + $vars = array(); + if (preg_match_all('/([\?\$]\{([^\}]+)\}|\([^\)]+\))/', $regex, $m)) { + $matches = $m[1]; + $pre_vars = $m[2]; + foreach ($matches as $i => $match) { + $vars[] = $pre_vars[$i]; + if ($pre_vars[$i]) {/* placeholder */ + $regex = str_replace($match, '(.+)', $regex); + } + else {/* parentheses, but may contain placeholders */ + $sub_regex = $match; + while (preg_match('/([\?\$]\{([^\}]+)\})/', $sub_regex, $m)) { + $sub_regex = str_replace($m[1], '(.+)', $sub_regex); + $vars[] = $m[2]; + } + $regex = str_replace($match, $sub_regex, $regex); + } + } + /* eval regex */ + if (@preg_match('/' . $regex . '/is', $input, $m)) { + $vals = $m; + } + else { + return 0; + } + for ($i = 0; $i < count($vars); $i++) { + if ($vars[$i]) { + $this->setVar($vars[$i], isset($vals[$i + 1]) ? $vals[$i + 1] : ''); + } + } + return 1; + } + /* no placeholders */ + return ($pattern == $input) ? 1 : 0; + } + + /* */ + +} \ No newline at end of file diff --git a/arc2-2.2.4/store/ARC2_MemStore.php b/arc2-2.2.4/store/ARC2_MemStore.php new file mode 100755 index 0000000..dc619fd --- /dev/null +++ b/arc2-2.2.4/store/ARC2_MemStore.php @@ -0,0 +1,194 @@ + + * @license http://arc.semsol.org/license + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_MemStore extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + $this->is_mem = 1; + } + + function __init() { + parent::__init(); + $this->data = array(); + } + + /* */ + + function isSetUp() { + return 1; + } + + function setUp() {} + + /* */ + + function reset() { + $this->data = array(); + } + + function drop() { + $this->reset(); + } + + /* */ + + function insert($doc, $g = 'http://localhost/') { + $index = $this->v($g, array(), $this->data); + $this->data[$g] = ARC2::getMergedIndex($index, $this->toIndex($doc)); + } + + /* */ + /* */ + + + function delete($doc, $g = 'http://localhost/') { + $index = $this->v($g, array(), $this->data); + $this->data[$g] = ARC2::getCleanedIndex($index, $this->toIndex($doc)); + } + + function replace($doc, $g, $doc_2) { + return array($this->delete($doc, $g), $this->insert($doc_2, $g)); + } + + /* */ + + function query($q, $result_format = '', $src = '', $keep_bnode_ids = 0, $log_query = 0) { + if ($log_query) $this->logQuery($q); + ARC2::inc('SPARQLPlusParser'); + $p = new ARC2_SPARQLPlusParser($this->a, $this); + $p->parse($q, $src); + $infos = $p->getQueryInfos(); + $t1 = ARC2::mtime(); + if (!$errs = $p->getErrors()) { + $qt = $infos['query']['type']; + $r = array('query_type' => $qt, 'result' => $this->runQuery($q, $qt)); + } + else { + $r = array('result' => ''); + } + $t2 = ARC2::mtime(); + $r['query_time'] = $t2 - $t1; + /* query result */ + if ($result_format == 'raw') { + return $r['result']; + } + if ($result_format == 'rows') { + return $this->v('rows', array(), $r['result']); + } + if ($result_format == 'row') { + return $r['result']['rows'] ? $r['result']['rows'][0] : array(); + } + return $r; + } + + function runQuery($q, $qt = '') { + /* ep */ + $ep = $this->v('remote_store_endpoint', 0, $this->a); + if (!$ep) return false; + /* prefixes */ + $ns = isset($this->a['ns']) ? $this->a['ns'] : array(); + $added_prefixes = array(); + $prologue = ''; + foreach ($ns as $k => $v) { + $k = rtrim($k, ':'); + if (in_array($k, $added_prefixes)) continue; + if (preg_match('/(^|\s)' . $k . ':/s', $q) && !preg_match('/PREFIX\s+' . $k . '\:/is', $q)) { + $prologue .= "\n" . 'PREFIX ' . $k . ': <' . $v . '>'; + } + $added_prefixes[] = $k; + } + $q = $prologue . "\n" . $q; + /* http verb */ + $mthd = in_array($qt, array('load', 'insert', 'delete')) ? 'POST' : 'GET'; + /* reader */ + ARC2::inc('Reader'); + $reader = new ARC2_Reader($this->a, $this); + $reader->setAcceptHeader('Accept: application/sparql-results+xml; q=0.9, application/rdf+xml; q=0.9, */*; q=0.1'); + if ($mthd == 'GET') { + $url = $ep; + $url .= strpos($ep, '?') ? '&' : '?'; + $url .= 'query=' . urlencode($q); + if ($k = $this->v('store_read_key', '', $this->a)) $url .= '&key=' . urlencode($k); + } + else { + $url = $ep; + $reader->setHTTPMethod($mthd); + $reader->setCustomHeaders("Content-Type: application/x-www-form-urlencoded"); + $suffix = ($k = $this->v('store_write_key', '', $this->a)) ? '&key=' . rawurlencode($k) : ''; + $reader->setMessageBody('query=' . rawurlencode($q) . $suffix); + } + $to = $this->v('remote_store_timeout', 0, $this->a); + $reader->activate($url, '', 0, $to); + $format = $reader->getFormat(); + $resp = ''; + while ($d = $reader->readStream()) { + $resp .= $d; + } + $reader->closeStream(); + $ers = $reader->getErrors(); + unset($this->reader); + if ($ers) return array('errors' => $ers); + $mappings = array('rdfxml' => 'RDFXML', 'sparqlxml' => 'SPARQLXMLResult', 'turtle' => 'Turtle'); + if (!$format || !isset($mappings[$format])) { + return $resp; + //return $this->addError('No parser available for "' . $format . '" SPARQL result'); + } + /* format parser */ + $suffix = $mappings[$format] . 'Parser'; + ARC2::inc($suffix); + $cls = 'ARC2_' . $suffix; + $parser = new $cls($this->a, $this); + $parser->parse($ep, $resp); + /* ask|load|insert|delete */ + if (in_array($qt, array('ask', 'load', 'insert', 'delete'))) { + $bid = $parser->getBooleanInsertedDeleted(); + switch ($qt) { + case 'ask': return $bid['boolean']; + default: return $bid; + } + } + /* select */ + if (($qt == 'select') && !method_exists($parser, 'getRows')) return $resp; + if ($qt == 'select') return array('rows' => $parser->getRows(), 'variables' => $parser->getVariables()); + /* any other */ + return $parser->getSimpleIndex(0); + } + + /* */ + + function optimizeTables() {} + + /* */ + + function getResourceLabel($res, $unnamed_label = 'An unnamed resource') { + if (!isset($this->resource_labels)) $this->resource_labels = array(); + if (isset($this->resource_labels[$res])) return $this->resource_labels[$res]; + if (!preg_match('/^[a-z0-9\_]+\:[^\s]+$/si', $res)) return $res;/* literal */ + $r = ''; + if (preg_match('/^\_\:/', $res)) { + return $unnamed_label; + } + $row = $this->query('SELECT ?o WHERE { <' . $res . '> ?p ?o . FILTER(REGEX(str(?p), "(label|name)$", "i"))}', 'row'); + if ($row) { + $r = $row['o']; + } + else { + $r = preg_replace("/^(.*[\/\#])([^\/\#]+)$/", '\\2', str_replace('#self', '', $res)); + $r = str_replace('_', ' ', $r); + $r = preg_replace('/([a-z])([A-Z])/e', '"\\1 " . strtolower("\\2")', $r); + } + $this->resource_labels[$res] = $r; + return $r; + } + +} diff --git a/arc2-2.2.4/store/ARC2_RemoteStore.php b/arc2-2.2.4/store/ARC2_RemoteStore.php new file mode 100755 index 0000000..c1f0f9e --- /dev/null +++ b/arc2-2.2.4/store/ARC2_RemoteStore.php @@ -0,0 +1,204 @@ + + * @license http://arc.semsol.org/license + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_RemoteStore extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + $this->is_remote = 1; + } + + function __init() { + parent::__init(); + } + + /* */ + + function isSetUp() { + return 1; + } + + function setUp() {} + + function killDBProcesses() {} + + /* */ + + function reset() {} + + function drop() {} + + function insert($doc, $g, $keep_bnode_ids = 0) { + return $this->query('INSERT INTO <' . $g . '> { ' . $this->toNTriples($doc, '', 1) . ' }'); + } + + function delete($doc, $g) { + if (!$doc) { + return $this->query('DELETE FROM <' . $g . '>'); + } + else { + return $this->query('DELETE FROM <' . $g . '> { ' . $this->toNTriples($doc, '', 1) . ' }'); + } + } + + function replace($doc, $g, $doc_2) { + return array($this->delete($doc, $g), $this->insert($doc_2, $g)); + } + + /* */ + + function query($q, $result_format = '', $src = '', $keep_bnode_ids = 0, $log_query = 0) { + if ($log_query) $this->logQuery($q); + ARC2::inc('SPARQLPlusParser'); + $p = new ARC2_SPARQLPlusParser($this->a, $this); + $p->parse($q, $src); + $infos = $p->getQueryInfos(); + $t1 = ARC2::mtime(); + if (!$errs = $p->getErrors()) { + $qt = $infos['query']['type']; + $r = array('query_type' => $qt, 'result' => $this->runQuery($q, $qt, $infos)); + } + else { + $r = array('result' => ''); + } + $t2 = ARC2::mtime(); + $r['query_time'] = $t2 - $t1; + /* query result */ + if ($result_format == 'raw') { + return $r['result']; + } + if ($result_format == 'rows') { + return $this->v('rows', array(), $r['result']); + } + if ($result_format == 'row') { + if (!isset($r['result']['rows'])) return array(); + return $r['result']['rows'] ? $r['result']['rows'][0] : array(); + } + return $r; + } + + function runQuery($q, $qt = '', $infos = '') { + /* ep */ + $ep = $this->v('remote_store_endpoint', 0, $this->a); + if (!$ep) return false; + /* prefixes */ + $q = $this->completeQuery($q); + /* custom handling */ + $mthd = 'run' . $this->camelCase($qt) . 'Query'; + if (method_exists($this, $mthd)) { + return $this->$mthd($q, $infos); + } + /* http verb */ + $mthd = in_array($qt, array('load', 'insert', 'delete')) ? 'POST' : 'GET'; + /* reader */ + ARC2::inc('Reader'); + $reader = new ARC2_Reader($this->a, $this); + $reader->setAcceptHeader('Accept: application/sparql-results+xml; q=0.9, application/rdf+xml; q=0.9, */*; q=0.1'); + if ($mthd == 'GET') { + $url = $ep; + $url .= strpos($ep, '?') ? '&' : '?'; + $url .= 'query=' . urlencode($q); + if ($k = $this->v('store_read_key', '', $this->a)) $url .= '&key=' . urlencode($k); + } + else { + $url = $ep; + $reader->setHTTPMethod($mthd); + $reader->setCustomHeaders("Content-Type: application/x-www-form-urlencoded"); + $suffix = ($k = $this->v('store_write_key', '', $this->a)) ? '&key=' . rawurlencode($k) : ''; + $reader->setMessageBody('query=' . rawurlencode($q) . $suffix); + } + $to = $this->v('remote_store_timeout', 0, $this->a); + $reader->activate($url, '', 0, $to); + $format = $reader->getFormat(); + $resp = ''; + while ($d = $reader->readStream()) { + $resp .= $this->toUTF8($d); + } + $reader->closeStream(); + $ers = $reader->getErrors(); + $this->a['reader_auth_infos'] = $reader->getAuthInfos(); + unset($this->reader); + if ($ers) return array('errors' => $ers); + $mappings = array('rdfxml' => 'RDFXML', 'sparqlxml' => 'SPARQLXMLResult', 'turtle' => 'Turtle'); + if (!$format || !isset($mappings[$format])) { + return $resp; + //return $this->addError('No parser available for "' . $format . '" SPARQL result'); + } + /* format parser */ + $suffix = $mappings[$format] . 'Parser'; + ARC2::inc($suffix); + $cls = 'ARC2_' . $suffix; + $parser = new $cls($this->a, $this); + $parser->parse($ep, $resp); + /* ask|load|insert|delete */ + if (in_array($qt, array('ask', 'load', 'insert', 'delete'))) { + $bid = $parser->getBooleanInsertedDeleted(); + if ($qt == 'ask') { + $r = $bid['boolean']; + } + else { + $r = $bid; + } + } + /* select */ + elseif (($qt == 'select') && !method_exists($parser, 'getRows')) { + $r = $resp; + } + elseif ($qt == 'select') { + $r = array('rows' => $parser->getRows(), 'variables' => $parser->getVariables()); + } + /* any other */ + else { + $r = $parser->getSimpleIndex(0); + } + unset($parser); + return $r; + } + + /* */ + + function optimizeTables() {} + + /* */ + + function getResourceLabel($res, $unnamed_label = 'An unnamed resource') { + if (!isset($this->resource_labels)) $this->resource_labels = array(); + if (isset($this->resource_labels[$res])) return $this->resource_labels[$res]; + if (!preg_match('/^[a-z0-9\_]+\:[^\s]+$/si', $res)) return $res;/* literal */ + $r = ''; + if (preg_match('/^\_\:/', $res)) { + return $unnamed_label; + } + $row = $this->query('SELECT ?o WHERE { <' . $res . '> ?p ?o . FILTER(REGEX(str(?p), "(label|name)$", "i"))}', 'row'); + if ($row) { + $r = $row['o']; + } + else { + $r = preg_replace("/^(.*[\/\#])([^\/\#]+)$/", '\\2', str_replace('#self', '', $res)); + $r = str_replace('_', ' ', $r); + $r = preg_replace('/([a-z])([A-Z])/e', '"\\1 " . strtolower("\\2")', $r); + } + $this->resource_labels[$res] = $r; + return $r; + } + + function getDomains($p) { + $r = array(); + foreach($this->query('SELECT DISTINCT ?type WHERE {?s <' . $p . '> ?o ; a ?type . }', 'rows') as $row) { + $r[] = $row['type']; + } + return $r; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_Store.php b/arc2-2.2.4/store/ARC2_Store.php new file mode 100755 index 0000000..78395aa --- /dev/null +++ b/arc2-2.2.4/store/ARC2_Store.php @@ -0,0 +1,721 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 +*/ + +ARC2::inc('Class'); + +class ARC2_Store extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* db_con */ + parent::__init(); + $this->table_lock = 0; + $this->triggers = $this->v('store_triggers', array(), $this->a); + $this->queue_queries = $this->v('store_queue_queries', 0, $this->a); + $this->is_win = (strtolower(substr(PHP_OS, 0, 3)) == 'win') ? true : false; + $this->max_split_tables = $this->v('store_max_split_tables', 10, $this->a); + $this->split_predicates = $this->v('store_split_predicates', array(), $this->a); + } + + /* */ + + function getName() { + return $this->v('store_name', 'arc', $this->a); + } + + function getTablePrefix() { + if (!isset($this->tbl_prefix)) { + $r = $this->v('db_table_prefix', '', $this->a); + $r .= $r ? '_' : ''; + $r .= $this->getName() . '_'; + $this->tbl_prefix = $r; + } + return $this->tbl_prefix;; + } + + /* */ + + function createDBCon() { + foreach (array('db_host' => 'localhost', 'db_user' => '', 'db_pwd' => '', 'db_name' => '') as $k => $v) { + $this->a[$k] = $this->v($k, $v, $this->a); + } + if (!$db_con = mysql_connect($this->a['db_host'], $this->a['db_user'], $this->a['db_pwd'])) { + return $this->addError(mysql_error()); + } + $this->a['db_con'] = $db_con; + if (!mysql_select_db($this->a['db_name'], $db_con)) { + $fixed = 0; + /* try to create it */ + if ($this->a['db_name']) { + $this->queryDB(" + CREATE DATABASE IF NOT EXISTS " . $this->a['db_name'] . " + DEFAULT CHARACTER SET utf8 + DEFAULT COLLATE utf8_general_ci + ", $db_con, 1 + ); + if (mysql_select_db($this->a['db_name'], $db_con)) { + $this->queryDB("SET NAMES 'utf8'", $db_con); + $fixed = 1; + } + } + if (!$fixed) { + return $this->addError(mysql_error($db_con)); + } + } + if (preg_match('/^utf8/', $this->getCollation())) { + $this->queryDB("SET NAMES 'utf8'", $db_con); + } + // This is RDF, we may need many JOINs... + $this->queryDB("SET SESSION SQL_BIG_SELECTS=1", $db_con); + return true; + } + + function getDBCon($force = 0) { + if ($force || !isset($this->a['db_con'])) { + if (!$this->createDBCon()) { + return false; + } + } + if (!$force && !@mysql_thread_id($this->a['db_con'])) return $this->getDBCon(1); + return $this->a['db_con']; + } + + function closeDBCon() { + if ($this->v('db_con', false, $this->a)) { + @mysql_close($this->a['db_con']); + } + unset($this->a['db_con']); + } + + function getDBVersion() { + if (!$this->v('db_version')) { + $this->db_version = preg_match("/^([0-9]+)\.([0-9]+)\.([0-9]+)/", mysql_get_server_info($this->getDBCon()), $m) ? sprintf("%02d-%02d-%02d", $m[1], $m[2], $m[3]) : '00-00-00'; + } + return $this->db_version; + } + + /* */ + + function getCollation() { + $rs = $this->queryDB('SHOW TABLE STATUS LIKE "' . $this->getTablePrefix(). 'setting"', $this->getDBCon()); + return ($rs && ($row = mysql_fetch_array($rs)) && isset($row['Collation'])) ? $row['Collation'] : ''; + } + + function getColumnType() { + if (!$this->v('column_type')) { + $tbl = $this->getTablePrefix() . 'g2t'; + $rs = $this->queryDB('SHOW COLUMNS FROM ' . $tbl . ' LIKE "t"', $this->getDBCon()); + $row = $rs ? mysql_fetch_array($rs) : array('Type' => 'mediumint'); + $this->column_type = preg_match('/mediumint/', $row['Type']) ? 'mediumint' : 'int'; + } + return $this->column_type; + } + + /* */ + + function hasHashColumn($tbl) { + $var_name = 'has_hash_column_' . $tbl; + if (!isset($this->$var_name)) { + $tbl = $this->getTablePrefix() . $tbl; + $rs = $this->queryDB('SHOW COLUMNS FROM ' . $tbl . ' LIKE "val_hash"', $this->getDBCon()); + $this->$var_name = ($rs && mysql_fetch_array($rs)); + } + return $this->$var_name; + } + + /* */ + + function hasFulltextIndex() { + if (!isset($this->has_fulltext_index)) { + $this->has_fulltext_index = 0; + $tbl = $this->getTablePrefix() . 'o2val'; + $rs = $this->queryDB('SHOW INDEX FROM ' . $tbl, $this->getDBCon()); + while ($row = mysql_fetch_array($rs)) { + if ($row['Column_name'] != 'val') continue; + if ($row['Index_type'] != 'FULLTEXT') continue; + $this->has_fulltext_index = 1; + break; + } + } + return $this->has_fulltext_index; + } + + function enableFulltextSearch() { + if ($this->hasFulltextIndex()) return 1; + $tbl = $this->getTablePrefix() . 'o2val'; + $this->queryDB('CREATE FULLTEXT INDEX vft ON ' . $tbl . '(val(128))', $this->getDBCon(), 1); + } + + function disableFulltextSearch() { + if (!$this->hasFulltextIndex()) return 1; + $tbl = $this->getTablePrefix() . 'o2val'; + $this->queryDB('DROP INDEX vft ON ' . $tbl, $this->getDBCon()); + } + + /* */ + + function countDBProcesses() { + return ($rs = $this->queryDB('SHOW PROCESSLIST', $this->getDBCon())) ? mysql_num_rows($rs) : 0; + } + + function killDBProcesses($needle = '', $runtime = 30) { + $dbcon = $this->getDBCon(); + /* make sure needle is sql */ + if (preg_match('/\?.+ WHERE/i', $needle, $m)) { + $needle = $this->query($needle, 'sql'); + } + $rs = $this->queryDB('SHOW FULL PROCESSLIST', $dbcon); + $ref_tbl = $this->getTablePrefix() . 'triple'; + while ($row = mysql_fetch_array($rs)) { + if ($row['Time'] < $runtime) continue; + if (!preg_match('/^\s*(INSERT|SELECT) /s', $row['Info'])) continue; /* only basic queries */ + if (!strpos($row['Info'], $ref_tbl . ' ')) continue; /* only from this store */ + $kill = 0; + if ($needle && (strpos($row['Info'], $needle) !== false)) $kill = 1; + if (!$needle) $kill = 1; + if (!$kill) continue; + $this->queryDB('KILL ' . $row['Id'], $dbcon); + } + } + + /* */ + + function getTables() { + return array('triple', 'g2t', 'id2val', 's2val', 'o2val', 'setting'); + } + + /* */ + + function isSetUp() { + if (($con = $this->getDBCon())) { + $tbl = $this->getTablePrefix() . 'setting'; + return $this->queryDB("SELECT 1 FROM " . $tbl . " LIMIT 0", $con) ? 1 : 0; + } + } + + function setUp($force = 0) { + if (($force || !$this->isSetUp()) && ($con = $this->getDBCon())) { + if ($this->getDBVersion() < '04-00-04') { + /* UPDATE + JOINs */ + return $this->addError('MySQL version not supported. ARC requires version 4.0.4 or higher.'); + } + ARC2::inc('StoreTableManager'); + $mgr = new ARC2_StoreTableManager($this->a, $this); + $mgr->createTables(); + } + } + + function extendColumns() { + ARC2::inc('StoreTableManager'); + $mgr = new ARC2_StoreTableManager($this->a, $this); + $mgr->extendColumns(); + $this->column_type = 'int'; + } + + function splitTables() { + ARC2::inc('StoreTableManager'); + $mgr = new ARC2_StoreTableManager($this->a, $this); + $mgr->splitTables(); + } + + /* */ + + function hasSetting($k) { + $tbl = $this->getTablePrefix() . 'setting'; + $sql = "SELECT val FROM " . $tbl . " WHERE k = '" .md5($k). "'"; + $rs = $this->queryDB($sql, $this->getDBCon()); + return ($rs && ($row = mysql_fetch_array($rs))) ? 1 : 0; + } + + function getSetting($k, $default = 0) { + $tbl = $this->getTablePrefix() . 'setting'; + $sql = "SELECT val FROM " . $tbl . " WHERE k = '" .md5($k). "'"; + $rs = $this->queryDB($sql, $this->getDBCon()); + if ($rs && ($row = mysql_fetch_array($rs))) { + return unserialize($row['val']); + } + return $default; + } + + function setSetting($k, $v) { + $con = $this->getDBCon(); + $tbl = $this->getTablePrefix() . 'setting'; + if ($this->hasSetting($k)) { + $sql = "UPDATE " .$tbl . " SET val = '" . mysql_real_escape_string(serialize($v), $con) . "' WHERE k = '" . md5($k) . "'"; + } + else { + $sql = "INSERT INTO " . $tbl . " (k, val) VALUES ('" . md5($k) . "', '" . mysql_real_escape_string(serialize($v), $con) . "')"; + } + return $this->queryDB($sql, $con); + } + + function removeSetting($k) { + $tbl = $this->getTablePrefix() . 'setting'; + return $this->queryDB("DELETE FROM " . $tbl . " WHERE k = '" . md5($k) . "'", $this->getDBCon()); + } + + function getQueueTicket() { + if (!$this->queue_queries) return 1; + $t = 'ticket_' . substr(md5(uniqid(rand())), 0, 10); + $con = $this->getDBCon(); + /* lock */ + $rs = $this->queryDB('LOCK TABLES ' . $this->getTablePrefix() . 'setting WRITE', $con); + /* queue */ + $queue = $this->getSetting('query_queue', array()); + $queue[] = $t; + $this->setSetting('query_queue', $queue); + $this->queryDB('UNLOCK TABLES', $con); + /* loop */ + $lc = 0; + $queue = $this->getSetting('query_queue', array()); + while ($queue && ($queue[0] != $t) && ($lc < 30)) { + if ($this->is_win) { + sleep(1); + $lc++; + } + else { + usleep(100000); + $lc += 0.1; + } + $queue = $this->getSetting('query_queue', array()); + } + return ($lc < 30) ? $t : 0; + } + + function removeQueueTicket($t) { + if (!$this->queue_queries) return 1; + $con = $this->getDBCon(); + /* lock */ + $this->queryDB('LOCK TABLES ' . $this->getTablePrefix() . 'setting WRITE', $con); + /* queue */ + $vals = $this->getSetting('query_queue', array()); + $pos = array_search($t, $vals); + $queue = ($pos < (count($vals) - 1)) ? array_slice($vals, $pos + 1) : array(); + $this->setSetting('query_queue', $queue); + $this->queryDB('UNLOCK TABLES', $con); + } + + /* */ + + function reset($keep_settings = 0) { + $con = $this->getDBCon(); + $tbls = $this->getTables(); + $prefix = $this->getTablePrefix(); + /* remove split tables */ + $ps = $this->getSetting('split_predicates', array()); + foreach ($ps as $p) { + $tbl = 'triple_' . abs(crc32($p)); + $this->queryDB('DROP TABLE ' . $prefix . $tbl, $con); + } + $this->removeSetting('split_predicates'); + /* truncate tables */ + foreach ($tbls as $tbl) { + if ($keep_settings && ($tbl == 'setting')) { + continue; + } + $this->queryDB('TRUNCATE ' . $prefix . $tbl, $con); + } + } + + function drop() { + $con = $this->getDBCon(); + $tbls = $this->getTables(); + $prefix = $this->getTablePrefix(); + foreach ($tbls as $tbl) { + $this->queryDB('DROP TABLE ' . $prefix . $tbl, $con); + } + } + + function insert($doc, $g, $keep_bnode_ids = 0) { + $doc = is_array($doc) ? $this->toTurtle($doc) : $doc; + $infos = array('query' => array('url' => $g, 'target_graph' => $g)); + ARC2::inc('StoreLoadQueryHandler'); + $h = new ARC2_StoreLoadQueryHandler($this->a, $this); + $r = $h->runQuery($infos, $doc, $keep_bnode_ids); + $this->processTriggers('insert', $infos); + return $r; + } + + function delete($doc, $g) { + if (!$doc) { + $infos = array('query' => array('target_graphs' => array($g))); + ARC2::inc('StoreDeleteQueryHandler'); + $h = new ARC2_StoreDeleteQueryHandler($this->a, $this); + $r = $h->runQuery($infos); + $this->processTriggers('delete', $infos); + return $r; + } + } + + function replace($doc, $g, $doc_2) { + return array($this->delete($doc, $g), $this->insert($doc_2, $g)); + } + + function dump() { + ARC2::inc('StoreDumper'); + $d = new ARC2_StoreDumper($this->a, $this); + $d->dumpSPOG(); + } + + function createBackup($path, $q = '') { + ARC2::inc('StoreDumper'); + $d = new ARC2_StoreDumper($this->a, $this); + $d->saveSPOG($path, $q); + } + + function renameTo($name) { + $con = $this->getDBCon(); + $tbls = $this->getTables(); + $old_prefix = $this->getTablePrefix(); + $new_prefix = $this->v('db_table_prefix', '', $this->a); + $new_prefix .= $new_prefix ? '_' : ''; + $new_prefix .= $name . '_'; + foreach ($tbls as $tbl) { + $rs = $this->queryDB('RENAME TABLE ' . $old_prefix . $tbl .' TO ' . $new_prefix . $tbl, $con); + $err = mysql_error($con); + if ($err) { + return $this->addError($err); + } + } + $this->a['store_name'] = $name; + unset($this->tbl_prefix); + } + + function replicateTo($name) { + $conf = array_merge($this->a, array('store_name' => $name)); + $new_store = ARC2::getStore($conf); + $new_store->setUp(); + $new_store->reset(); + $con = $this->getDBCon(); + $tbls = $this->getTables(); + $old_prefix = $this->getTablePrefix(); + $new_prefix = $new_store->getTablePrefix(); + foreach ($tbls as $tbl) { + $rs = $this->queryDB('INSERT IGNORE INTO ' . $new_prefix . $tbl .' SELECT * FROM ' . $old_prefix . $tbl, $con); + $err = mysql_error($con); + if ($err) { + return $this->addError($err); + } + } + return $new_store->query('SELECT COUNT(*) AS t_count WHERE { ?s ?p ?o}', 'row'); + } + + /* */ + + function query($q, $result_format = '', $src = '', $keep_bnode_ids = 0, $log_query = 0) { + if ($log_query) $this->logQuery($q); + $con = $this->getDBCon(); + if (preg_match('/^dump/i', $q)) { + $infos = array('query' => array('type' => 'dump')); + } + else { + ARC2::inc('SPARQLPlusParser'); + $p = new ARC2_SPARQLPlusParser($this->a, $this); + $p->parse($q, $src); + $infos = $p->getQueryInfos(); + } + if ($result_format == 'infos') return $infos; + $infos['result_format'] = $result_format; + if (!isset($p) || !$p->getErrors()) { + $qt = $infos['query']['type']; + if (!in_array($qt, array('select', 'ask', 'describe', 'construct', 'load', 'insert', 'delete', 'dump'))) { + return $this->addError('Unsupported query type "'.$qt.'"'); + } + $t1 = ARC2::mtime(); + $r = array('query_type' => $qt, 'result' => $this->runQuery($infos, $qt, $keep_bnode_ids, $q)); + $t2 = ARC2::mtime(); + $r['query_time'] = $t2 - $t1; + /* query result */ + if ($result_format == 'raw') { + return $r['result']; + } + if ($result_format == 'rows') { + return $r['result']['rows'] ? $r['result']['rows'] : array(); + } + if ($result_format == 'row') { + return $r['result']['rows'] ? $r['result']['rows'][0] : array(); + } + return $r; + } + return 0; + } + + function runQuery($infos, $type, $keep_bnode_ids = 0, $q = '') { + ARC2::inc('Store' . ucfirst($type) . 'QueryHandler'); + $cls = 'ARC2_Store' . ucfirst($type) . 'QueryHandler'; + $h = new $cls($this->a, $this); + $ticket = 1; + $r = array(); + if ($q && ($type == 'select')) $ticket = $this->getQueueTicket($q); + if ($ticket) { + if ($type == 'load') {/* the LoadQH supports raw data as 2nd parameter */ + $r = $h->runQuery($infos, '', $keep_bnode_ids); + } + else { + $r = $h->runQuery($infos, $keep_bnode_ids); + } + } + if ($q && ($type == 'select')) $this->removeQueueTicket($ticket); + $trigger_r = $this->processTriggers($type, $infos); + return $r; + } + + function processTriggers($type, $infos) { + $r = array(); + $trigger_defs = $this->triggers; + $this->triggers = array(); + $triggers = $this->v($type, array(), $trigger_defs); + if ($triggers) { + $r['trigger_results'] = array(); + $triggers = is_array($triggers) ? $triggers : array($triggers); + $trigger_inc_path = $this->v('store_triggers_path', '', $this->a); + foreach ($triggers as $trigger) { + $trigger .= !preg_match('/Trigger$/', $trigger) ? 'Trigger' : ''; + if (ARC2::inc(ucfirst($trigger), $trigger_inc_path)) { + $cls = 'ARC2_' . ucfirst($trigger); + $config = array_merge($this->a, array('query_infos' => $infos)); + $trigger_obj = new $cls($config, $this); + if (method_exists($trigger_obj, 'go')) { + $r['trigger_results'][] = $trigger_obj->go(); + } + } + } + } + $this->triggers = $trigger_defs; + return $r; + } + + /* */ + + function getValueHash($val, $_32bit = false) { + $hash = crc32($val); + if ($_32bit && ($hash & 0x80000000)) { + $hash = sprintf("%u", $hash); + } + $hash = abs($hash); + return $hash; + } + + function getTermID($val, $term = '') { + /* mem cache */ + if (!isset($this->term_id_cache) || (count(array_keys($this->term_id_cache)) > 100)) { + $this->term_id_cache = array(); + } + if (!isset($this->term_id_cache[$term])) { + $this->term_id_cache[$term] = array(); + } + $tbl = preg_match('/^(s|o)$/', $term) ? $term . '2val' : 'id2val'; + /* cached? */ + if ((strlen($val) < 100) && isset($this->term_id_cache[$term][$val])) { + return $this->term_id_cache[$term][$val]; + } + $con = $this->getDBCon(); + $r = 0; + /* via hash */ + if (preg_match('/^(s2val|o2val)$/', $tbl) && $this->hasHashColumn($tbl)) { + $sql = "SELECT id, val FROM " . $this->getTablePrefix() . $tbl . " WHERE val_hash = '" . $this->getValueHash($val) . "'"; + $rs = $this->queryDB($sql, $con); + if (!$rs || !mysql_num_rows($rs)) {// try 32 bit version + $sql = "SELECT id, val FROM " . $this->getTablePrefix() . $tbl . " WHERE val_hash = '" . $this->getValueHash($val, true) . "'"; + $rs = $this->queryDB($sql, $con); + } + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs)) { + while ($row = mysql_fetch_array($rs)) { + if ($row['val'] == $val) { + $r = $row['id']; + break; + } + } + } + } + /* exact match */ + else { + $sql = "SELECT id FROM " . $this->getTablePrefix() . $tbl . " WHERE val = BINARY '" . mysql_real_escape_string($val, $con) . "' LIMIT 1"; + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs) && ($row = mysql_fetch_array($rs))) { + $r = $row['id']; + } + } + if ($r && (strlen($val) < 100)) { + $this->term_id_cache[$term][$val] = $r; + } + return $r; + } + + function getIDValue($id, $term = '') { + $tbl = preg_match('/^(s|o)$/', $term) ? $term . '2val' : 'id2val'; + $con = $this->getDBCon(); + $sql = "SELECT val FROM " . $this->getTablePrefix() . $tbl . " WHERE id = " . mysql_real_escape_string($id, $con) . " LIMIT 1"; + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs) && ($row = mysql_fetch_array($rs))) { + return $row['val']; + } + return 0; + } + + /* */ + + function getLock($t_out = 10, $t_out_init = '') { + if (!$t_out_init) $t_out_init = $t_out; + $con = $this->getDBCon(); + $l_name = $this->a['db_name'] . '.' . $this->getTablePrefix() . '.write_lock'; + $rs = $this->queryDB('SELECT IS_FREE_LOCK("' . $l_name. '") AS success', $con); + if ($rs) { + $row = mysql_fetch_array($rs); + if (!$row['success']) { + if ($t_out) { + sleep(1); + return $this->getLock($t_out - 1, $t_out_init); + } + } + else { + $rs = $this->queryDB('SELECT GET_LOCK("' . $l_name. '", ' . $t_out_init. ') AS success', $con); + if ($rs) { + $row = mysql_fetch_array($rs); + return $row['success']; + } + } + } + return 0; + } + + function releaseLock() { + $con = $this->getDBCon(); + return $this->queryDB('DO RELEASE_LOCK("' . $this->a['db_name'] . '.' . $this->getTablePrefix() . '.write_lock")', $con); + } + + /* */ + + function processTables($level = 2, $operation = 'optimize') {/* 1: triple + g2t, 2: triple + *2val, 3: all tables */ + $con = $this->getDBCon(); + $pre = $this->getTablePrefix(); + $tbls = $this->getTables(); + $sql = ''; + foreach ($tbls as $tbl) { + if (($level < 3) && preg_match('/(backup|setting)$/', $tbl)) continue; + if (($level < 2) && preg_match('/(val)$/', $tbl)) continue; + $sql .= $sql ? ', ' : strtoupper($operation) . ' TABLE '; + $sql .= $pre . $tbl; + } + $this->queryDB($sql, $con); + $err = mysql_error($con); + if ($err) { + $this->addError($err . ' in ' . $sql); + } + } + + function optimizeTables($level = 2) { + if ($this->v('ignore_optimization')) return 1; + return $this->processTables($level, 'optimize'); + } + + function checkTables($level = 2) { + return $this->processTables($level, 'check'); + } + + function repairTables($level = 2) { + return $this->processTables($level, 'repair'); + } + + /* */ + + function changeNamespaceURI($old_uri, $new_uri) { + ARC2::inc('StoreHelper'); + $c = new ARC2_StoreHelper($this->a, $this); + return $c->changeNamespaceURI($old_uri, $new_uri); + } + + /* */ + + function getResourceLabel($res, $unnamed_label = 'An unnamed resource') { + if (!isset($this->resource_labels)) $this->resource_labels = array(); + if (isset($this->resource_labels[$res])) return $this->resource_labels[$res]; + if (!preg_match('/^[a-z0-9\_]+\:[^\s]+$/si', $res)) return $res;/* literal */ + $ps = $this->getLabelProps(); + if ($this->getSetting('store_label_properties', '-') != md5(serialize($ps))) { + $this->inferLabelProps($ps); + } + //$sub_q .= $sub_q ? ' || ' : ''; + //$sub_q .= 'REGEX(str(?p), "(last_name|name|fn|title|label)$", "i")'; + $q = 'SELECT ?label WHERE { <' . $res . '> ?p ?label . ?p a } LIMIT 3'; + $r = ''; + $rows = $this->query($q, 'rows'); + foreach ($rows as $row) { + $r = strlen($row['label']) > strlen($r) ? $row['label'] : $r; + } + if (!$r && preg_match('/^\_\:/', $res)) { + return $unnamed_label; + } + $r = $r ? $r : preg_replace("/^(.*[\/\#])([^\/\#]+)$/", '\\2', str_replace('#self', '', $res)); + $r = str_replace('_', ' ', $r); + $r = preg_replace('/([a-z])([A-Z])/e', '"\\1 " . strtolower("\\2")', $r); + $this->resource_labels[$res] = $r; + return $r; + } + + function getLabelProps() { + return array_merge( + $this->v('rdf_label_properties' , array(), $this->a), + array( + 'http://www.w3.org/2000/01/rdf-schema#label', + 'http://xmlns.com/foaf/0.1/name', + 'http://purl.org/dc/elements/1.1/title', + 'http://purl.org/rss/1.0/title', + 'http://www.w3.org/2004/02/skos/core#prefLabel', + 'http://xmlns.com/foaf/0.1/nick', + ) + ); + } + + function inferLabelProps($ps) { + $this->query('DELETE FROM '); + $sub_q = ''; + foreach ($ps as $p) { + $sub_q .= ' <' . $p . '> a . '; + } + $this->query('INSERT INTO { ' . $sub_q. ' }'); + $this->setSetting('store_label_properties', md5(serialize($ps))); + } + + /* */ + + function getResourcePredicates($res) { + $r = array(); + $rows = $this->query('SELECT DISTINCT ?p WHERE { <' . $res . '> ?p ?o . }', 'rows'); + foreach ($rows as $row) { + $r[$row['p']] = array(); + } + return $r; + } + + function getDomains($p) { + $r = array(); + foreach($this->query('SELECT DISTINCT ?type WHERE {?s <' . $p . '> ?o ; a ?type . }', 'rows') as $row) { + $r[] = $row['type']; + } + return $r; + } + + function getPredicateRange($p) { + $row = $this->query('SELECT ?val WHERE {<' . $p . '> rdfs:range ?val . } LIMIT 1', 'row'); + return $row ? $row['val'] : ''; + } + + /* */ + + function logQuery($q) { + $fp = @fopen("arc_query_log.txt", "a"); + @fwrite($fp, date('Y-m-d\TH:i:s\Z', time()) . ' : ' . $q . '' . "\n\n"); + @fclose($fp); + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreAskQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreAskQueryHandler.php new file mode 100755 index 0000000..3515536 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreAskQueryHandler.php @@ -0,0 +1,53 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('StoreSelectQueryHandler'); + +class ARC2_StoreAskQueryHandler extends ARC2_StoreSelectQueryHandler { + + function __construct($a, &$caller) {/* caller has to be a store */ + parent::__construct($a, $caller); + } + + function __init() {/* db_con */ + parent::__init(); + $this->store = $this->caller; + } + + /* */ + + function runQuery($infos) { + $infos['query']['limit'] = 1; + $this->infos = $infos; + $this->buildResultVars(); + return parent::runQuery($this->infos); + } + + /* */ + + function buildResultVars() { + $this->infos['query']['result_vars'][] = array('var' => '1', 'aggregate' => '', 'alias' => 'success'); + } + + /* */ + + function getFinalQueryResult($q_sql, $tmp_tbl) { + $con = $this->store->getDBCon(); + $rs = mysql_query('SELECT success FROM ' . $tmp_tbl, $con); + $r = ($row = mysql_fetch_array($rs)) ? $row['success'] : 0; + return $r ? true : false; + } + + /* */ + +} + + diff --git a/arc2-2.2.4/store/ARC2_StoreAtomLoader.php b/arc2-2.2.4/store/ARC2_StoreAtomLoader.php new file mode 100755 index 0000000..2070df0 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreAtomLoader.php @@ -0,0 +1,32 @@ +caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreCBJSONLoader.php b/arc2-2.2.4/store/ARC2_StoreCBJSONLoader.php new file mode 100755 index 0000000..ae262b5 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreCBJSONLoader.php @@ -0,0 +1,38 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('CBJSONParser'); + +class ARC2_StoreCBJSONLoader extends ARC2_CBJSONParser { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + } + + /* */ + + function done() { + $this->extractRDF(); + } + + function addT($s, $p, $o, $s_type, $o_type, $o_dt = '', $o_lang = '') { + $o = $this->toUTF8($o); + $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreConstructQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreConstructQueryHandler.php new file mode 100755 index 0000000..865ba93 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreConstructQueryHandler.php @@ -0,0 +1,115 @@ +store = $this->caller; + } + + /* */ + + function runQuery($infos) { + $this->infos = $infos; + $this->buildResultVars(); + $this->infos['query']['distinct'] = 1; + $sub_r = parent::runQuery($this->infos); + $rf = $this->v('result_format', '', $infos); + if (in_array($rf, array('sql', 'structure', 'index'))) { + return $sub_r; + } + return $this->getResultIndex($sub_r); + } + + /* */ + + function buildResultVars() { + $r = array(); + foreach ($this->infos['query']['construct_triples'] as $t) { + foreach (array('s', 'p', 'o') as $term) { + if ($t[$term . '_type'] == 'var') { + if (!in_array($t[$term], $r)) { + $r[] = array('var' => $t[$term], 'aggregate' => '', 'alias' => ''); + } + } + } + } + $this->infos['query']['result_vars'] = $r; + } + + /* */ + + function getResultIndex($qr) { + $r = array(); + $added = array(); + $rows = $this->v('rows', array(), $qr); + $cts = $this->infos['query']['construct_triples']; + $bnc = 0; + foreach ($rows as $row) { + $bnc++; + foreach ($cts as $ct) { + $skip_t = 0; + $t = array(); + foreach (array('s', 'p', 'o') as $term) { + $val = $ct[$term]; + $type = $ct[$term . '_type']; + $val = ($type == 'bnode') ? $val . $bnc : $val; + if ($type == 'var') { + $skip_t = !isset($row[$val]) ? 1 : $skip_t; + $type = !$skip_t ? $row[$val . ' type'] : ''; + $val = (!$skip_t) ? $row[$val] : ''; + } + $t[$term] = $val; + $t[$term . '_type'] = $type; + if (isset($row[$ct[$term] . ' lang'])) { + $t[$term . '_lang'] = $row[$ct[$term] . ' lang']; + } + if (isset($row[$ct[$term] . ' datatype'])) { + $t[$term . '_datatype'] = $row[$ct[$term] . ' datatype']; + } + } + if (!$skip_t) { + $s = $t['s']; + $p = $t['p']; + $o = $t['o']; + if (!isset($r[$s])) { + $r[$s] = array(); + } + if (!isset($r[$s][$p])) { + $r[$s][$p] = array(); + } + $o = array('value' => $o); + foreach (array('lang', 'type', 'datatype') as $suffix) { + if (isset($t['o_' . $suffix]) && $t['o_' . $suffix]) { + $o[$suffix] = $t['o_' . $suffix]; + } + } + if (!isset($added[md5($s . ' ' . $p . ' ' . serialize($o))])) { + $r[$s][$p][] = $o; + $added[md5($s . ' ' . $p . ' ' . serialize($o))] = 1; + } + } + } + } + return $r; + } + + /* */ + +} + + diff --git a/arc2-2.2.4/store/ARC2_StoreDeleteQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreDeleteQueryHandler.php new file mode 100755 index 0000000..301219a --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreDeleteQueryHandler.php @@ -0,0 +1,233 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 +*/ + +ARC2::inc('StoreQueryHandler'); + +class ARC2_StoreDeleteQueryHandler extends ARC2_StoreQueryHandler { + + function __construct($a, &$caller) {/* caller has to be a store */ + parent::__construct($a, $caller); + } + + function __init() {/* db_con */ + parent::__init(); + $this->store = $this->caller; + $this->handler_type = 'delete'; + } + + /* */ + + function runQuery($infos) { + $this->infos = $infos; + $con = $this->store->getDBCon(); + $t1 = ARC2::mtime(); + /* delete */ + $this->refs_deleted = false; + /* graph(s) only */ + if (!$this->v('construct_triples', array(), $this->infos['query'])) { + $tc = $this->deleteTargetGraphs(); + } + /* graph(s) + explicit triples */ + elseif (!$this->v('pattern', array(), $this->infos['query'])) { + $tc = $this->deleteTriples(); + } + /* graph(s) + constructed triples */ + else { + $tc = $this->deleteConstructedGraph(); + } + $t2 = ARC2::mtime(); + /* clean up */ + if ($tc && ($this->refs_deleted || (rand(1, 100) == 1))) $this->cleanTableReferences(); + if ($tc && (rand(1, 100) == 1)) $this->store->optimizeTables(); + if ($tc && (rand(1, 500) == 1)) $this->cleanValueTables(); + $t3 = ARC2::mtime(); + $index_dur = round($t3 - $t2, 4); + $dur = round($t3 - $t1, 4); + return array( + 't_count' => $tc, + 'delete_time' => $dur, + 'index_update_time' => $index_dur, + ); + } + + /* */ + + function deleteTargetGraphs() { + $tbl_prefix = $this->store->getTablePrefix(); + $r = 0; + $con = $this->store->getDBCon(); + foreach ($this->infos['query']['target_graphs'] as $g) { + if ($g_id = $this->getTermID($g, 'g')) { + $rs = mysql_query('DELETE FROM ' . $tbl_prefix . 'g2t WHERE g = ' .$g_id, $con); + $r += mysql_affected_rows($con); + } + } + $this->refs_deleted = $r ? 1 : 0; + return $r; + } + + /* */ + + function deleteTriples() { + $r = 0; + $dbv = $this->store->getDBVersion(); + $tbl_prefix = $this->store->getTablePrefix(); + $con = $this->store->getDBCon(); + /* graph restriction */ + $tgs = $this->infos['query']['target_graphs']; + $gq = ''; + foreach ($tgs as $g) { + if ($g_id = $this->getTermID($g, 'g')) { + $gq .= $gq ? ', ' . $g_id : $g_id; + } + } + $gq = $gq ? ' AND G.g IN (' . $gq . ')' : ''; + /* triples */ + foreach ($this->infos['query']['construct_triples'] as $t) { + $q = ''; + $skip = 0; + foreach (array('s', 'p', 'o') as $term) { + if (isset($t[$term . '_type']) && preg_match('/(var)/', $t[$term . '_type'])) { + //$skip = 1; + } + else { + $term_id = $this->getTermID($t[$term], $term); + $q .= ($q ? ' AND ' : '') . 'T.' . $term . '=' . $term_id; + /* explicit lang/dt restricts the matching */ + if ($term == 'o') { + $o_lang = $this->v1('o_lang', '', $t); + $o_lang_dt = $this->v1('o_datatype', $o_lang, $t); + if ($o_lang_dt) { + $q .= ($q ? ' AND ' : '') . 'T.o_lang_dt=' . $this->getTermID($o_lang_dt, 'lang_dt'); + } + } + } + } + if ($skip) { + continue; + } + if ($gq) { + $sql = ($dbv < '04-01') ? 'DELETE ' . $tbl_prefix . 'g2t' : 'DELETE G'; + $sql .= ' + FROM ' . $tbl_prefix . 'g2t G + JOIN ' . $this->getTripleTable() . ' T ON (T.t = G.t' . $gq . ') + WHERE ' . $q . ' + '; + $this->refs_deleted = 1; + } + else {/* triples only */ + $sql = ($dbv < '04-01') ? 'DELETE ' . $this->getTripleTable() : 'DELETE T'; + $sql .= ' FROM ' . $this->getTripleTable() . ' T WHERE ' . $q; + } + //$rs = mysql_query($sql, $con); + $rs = $this->queryDB($sql, $con); + if ($er = mysql_error($con)) { + $this->addError($er .' in ' . $sql); + } + $r += mysql_affected_rows($con); + } + return $r; + } + + /* */ + + function deleteConstructedGraph() { + ARC2::inc('StoreConstructQueryHandler'); + $h = new ARC2_StoreConstructQueryHandler($this->a, $this->store); + $sub_r = $h->runQuery($this->infos); + $triples = ARC2::getTriplesFromIndex($sub_r); + $tgs = $this->infos['query']['target_graphs']; + $this->infos = array('query' => array('construct_triples' => $triples, 'target_graphs' => $tgs)); + return $this->deleteTriples(); + } + + /* */ + + function cleanTableReferences() { + /* lock */ + if (!$this->store->getLock()) return $this->addError('Could not get lock in "cleanTableReferences"'); + $con = $this->store->getDBCon(); + $tbl_prefix = $this->store->getTablePrefix(); + $dbv = $this->store->getDBVersion(); + /* check for unconnected triples */ + $sql = ' + SELECT T.t FROM '. $tbl_prefix . 'triple T LEFT JOIN '. $tbl_prefix . 'g2t G ON ( G.t = T.t ) + WHERE G.t IS NULL LIMIT 1 + '; + if (($rs = mysql_query($sql, $con)) && mysql_num_rows($rs)) { + /* delete unconnected triples */ + $sql = ($dbv < '04-01') ? 'DELETE ' . $tbl_prefix . 'triple' : 'DELETE T'; + $sql .= ' + FROM ' . $tbl_prefix . 'triple T + LEFT JOIN ' . $tbl_prefix . 'g2t G ON (G.t = T.t) + WHERE G.t IS NULL + '; + mysql_query($sql, $con); + } + /* check for unconnected graph refs */ + if ((rand(1, 10) == 1)) { + $sql = ' + SELECT G.g FROM '. $tbl_prefix . 'g2t G LEFT JOIN '. $tbl_prefix . 'triple T ON ( T.t = G.t ) + WHERE T.t IS NULL LIMIT 1 + '; + if (($rs = mysql_query($sql, $con)) && mysql_num_rows($rs)) { + /* delete unconnected graph refs */ + $sql = ($dbv < '04-01') ? 'DELETE ' . $tbl_prefix . 'g2t' : 'DELETE G'; + $sql .= ' + FROM ' . $tbl_prefix . 'g2t G + LEFT JOIN ' . $tbl_prefix . 'triple T ON (T.t = G.t) + WHERE T.t IS NULL + '; + mysql_query($sql, $con); + } + } + /* release lock */ + $this->store->releaseLock(); + } + + /* */ + + function cleanValueTables() { + /* lock */ + if (!$this->store->getLock()) return $this->addError('Could not get lock in "cleanValueTables"'); + $con = $this->store->getDBCon(); + $tbl_prefix = $this->store->getTablePrefix(); + $dbv = $this->store->getDBVersion(); + /* o2val */ + $sql = ($dbv < '04-01') ? 'DELETE ' . $tbl_prefix . 'o2val' : 'DELETE V'; + $sql .= ' + FROM ' . $tbl_prefix . 'o2val V + LEFT JOIN ' . $tbl_prefix . 'triple T ON (T.o = V.id) + WHERE T.t IS NULL + '; + mysql_query($sql, $con); + /* s2val */ + $sql = ($dbv < '04-01') ? 'DELETE ' . $tbl_prefix . 's2val' : 'DELETE V'; + $sql .= ' + FROM ' . $tbl_prefix . 's2val V + LEFT JOIN ' . $tbl_prefix . 'triple T ON (T.s = V.id) + WHERE T.t IS NULL + '; + mysql_query($sql, $con); + /* id2val */ + $sql = ($dbv < '04-01') ? 'DELETE ' . $tbl_prefix . 'id2val' : 'DELETE V'; + $sql .= ' + FROM ' . $tbl_prefix . 'id2val V + LEFT JOIN ' . $tbl_prefix . 'g2t G ON (G.g = V.id) + LEFT JOIN ' . $tbl_prefix . 'triple T1 ON (T1.p = V.id) + LEFT JOIN ' . $tbl_prefix . 'triple T2 ON (T2.o_lang_dt = V.id) + WHERE G.g IS NULL AND T1.t IS NULL AND T2.t IS NULL + '; + //mysql_query($sql, $con); + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreDescribeQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreDescribeQueryHandler.php new file mode 100755 index 0000000..eb71b08 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreDescribeQueryHandler.php @@ -0,0 +1,119 @@ +store = $this->caller; + $this->detect_labels = $this->v('detect_describe_query_labels', 0, $this->a); + } + + /* */ + + function runQuery($infos) { + $ids = $infos['query']['result_uris']; + if ($vars = $infos['query']['result_vars']) { + $sub_r = parent::runQuery($infos); + $rf = $this->v('result_format', '', $infos); + if (in_array($rf, array('sql', 'structure', 'index'))) { + return $sub_r; + } + $rows = $this->v('rows', array(), $sub_r); + foreach ($rows as $row) { + foreach ($vars as $info) { + $val = isset($row[$info['var']]) ? $row[$info['var']] : ''; + if ($val && ($row[$info['var'] . ' type'] != 'literal') && !in_array($val, $ids)) { + $ids[] = $val; + } + } + } + } + $this->r = array(); + $this->described_ids = array(); + $this->ids = $ids; + $this->added_triples = array(); + $is_sub_describe = 0; + while ($this->ids) { + $id = $this->ids[0]; + $this->described_ids[] = $id; + if ($this->detect_labels) { + $q = ' + CONSTRUCT { + <' . $id . '> ?p ?o . + ?o ?label_p ?o_label . + ?o ?o_label . + } WHERE { + <' . $id . '> ?p ?o . + OPTIONAL { + ?o ?label_p ?o_label . + FILTER REGEX(str(?label_p), "(name|label|title|summary|nick|fn)$", "i") + } + } + '; + } + else { + $q = ' + CONSTRUCT { + <' . $id . '> ?p ?o . + } WHERE { + <' . $id . '> ?p ?o . + } + '; + } + $sub_r = $this->store->query($q); + $sub_index = is_array($sub_r['result']) ? $sub_r['result'] : array(); + $this->mergeSubResults($sub_index, $is_sub_describe); + $is_sub_describe = 1; + } + return $this->r; + } + + /* */ + + function mergeSubResults($index, $is_sub_describe = 1) { + foreach ($index as $s => $ps) { + if (!isset($this->r[$s])) $this->r[$s] = array(); + foreach ($ps as $p => $os) { + if (!isset($this->r[$s][$p])) $this->r[$s][$p] = array(); + foreach ($os as $o) { + $id = md5($s . ' ' . $p . ' ' . serialize($o)); + if (!isset($this->added_triples[$id])) { + if (1 || !$is_sub_describe) { + $this->r[$s][$p][] = $o; + if (is_array($o) && ($o['type'] == 'bnode') && !in_array($o['value'], $this->ids)) $this->ids[] = $o['value']; + } + elseif (!is_array($o) || ($o['type'] != 'bnode')) { + $this->r[$s][$p][] = $o; + } + $this->added_triples[$id] = 1; + } + } + } + } + /* adjust ids */ + $ids = $this->ids; + $this->ids = array(); + foreach ($ids as $id) { + if (!in_array($id, $this->described_ids)) $this->ids[] = $id; + } + } + + /* */ + +} + + diff --git a/arc2-2.2.4/store/ARC2_StoreDumpQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreDumpQueryHandler.php new file mode 100755 index 0000000..cbcdaa0 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreDumpQueryHandler.php @@ -0,0 +1,37 @@ +store = $this->caller; + } + + /* */ + + function runQuery($infos, $keep_bnode_ids = 0) { + $this->infos = $infos; + $con = $this->store->getDBCon(); + ARC2::inc('StoreDumper'); + $d = new ARC2_StoreDumper($this->a, $this->store); + $d->dumpSPOG(); + return 1; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreDumper.php b/arc2-2.2.4/store/ARC2_StoreDumper.php new file mode 100755 index 0000000..931fa92 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreDumper.php @@ -0,0 +1,222 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_StoreDumper extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->store = $this->caller; + $this->keep_time_limit = $this->v('keep_time_limit', 0, $this->a); + $this->limit = 100000; + } + + /* */ + + function dumpSPOG() { + header('Content-Type: application/sparql-results+xml'); + if ($this->v('store_use_dump_dir', 0, $this->a)) { + $path = $this->v('store_dump_dir', 'dumps', $this->a); + /* default: monthly dumps */ + $path_suffix = $this->v('store_dump_suffix', date('Y_m'), $this->a); + $path .= '/dump_' . $path_suffix . '.spog'; + if (!file_exists($path)) { + $this->saveSPOG($path); + } + readfile($path); + exit; + } + echo $this->getHeader(); + $offset = 0; + do { + $proceed = 0; + $rs = $this->getRecordset($offset); + if (!$rs) break; + while ($row = mysql_fetch_array($rs)) { + echo $this->getEntry($row); + $proceed = 1; + } + $offset += $this->limit; + } while ($proceed); + echo $this->getFooter(); + } + + /* */ + + function saveSPOG($path, $q = '') { + if ($q) return $this->saveCustomSPOG($path, $q); + if (!$fp = @fopen($path, 'w')) return $this->addError('Could not create backup file at ' . realpath($path)); + fwrite($fp, $this->getHeader()); + $offset = 0; + do { + $proceed = 0; + $rs = $this->getRecordset($offset); + if (!$rs) break; + while ($row = mysql_fetch_array($rs)) { + fwrite($fp, $this->getEntry($row)); + $proceed = 1; + } + $offset += $this->limit; + } while ($proceed); + fwrite($fp, $this->getFooter()); + @fclose($fp); + return 1; + } + + /* */ + + function saveCustomSPOG($path, $q) { + if (!$fp = @fopen($path, 'w')) return $this->addError('Could not create backup file at ' . realpath($path)); + fwrite($fp, $this->getHeader()); + $rows = $this->store->query($q, 'rows'); + foreach ($rows as $row) { + fwrite($fp, $this->getEntry($row)); + } + fwrite($fp, $this->getFooter()); + @fclose($fp); + } + + /* */ + + function getRecordset($offset) { + $prefix = $this->store->getTablePrefix(); + $con = $this->store->getDBCon(); + $sql = ' + SELECT + VS.val AS s, + T.s_type AS `s type`, + VP.val AS p, + 0 AS `p type`, + VO.val AS o, + T.o_type AS `o type`, + VLDT.val as `o lang_dt`, + VG.val as g, + 0 AS `g type` + FROM + ' . $prefix . 'triple T + JOIN ' . $prefix . 's2val VS ON (T.s = VS.id) + JOIN ' . $prefix . 'id2val VP ON (T.p = VP.id) + JOIN ' . $prefix . 'o2val VO ON (T.o = VO.id) + JOIN ' . $prefix . 'id2val VLDT ON (T.o_lang_dt = VLDT.id) + JOIN ' . $prefix . 'g2t G2T ON (T.t = G2T.t) + JOIN ' . $prefix . 'id2val VG ON (G2T.g = VG.id) + '; + if ($this->limit) $sql .= ' LIMIT ' . $this->limit; + if ($offset) $sql .= ' OFFSET ' . $offset; + $rs = mysql_unbuffered_query($sql, $con); + if (($err = mysql_error($con))) { + return $this->addError($err); + } + return $rs; + } + + /* */ + + function getHeader() { + $n = "\n"; + return '' . + '' . + $n . '' . + $n . ' ' . + $n . ' ' . + $n . ' ' . + $n . ' ' . + $n . ' ' . + $n . ' ' . + $n . ' ' . + ''; + } + + function getEntry($row) { + if (!$this->keep_time_limit) @set_time_limit($this->v('time_limit', 1200, $this->a)); + $n = "\n"; + $r = ''; + $r .= $n . ' '; + foreach (array('s', 'p', 'o', 'g') as $var) { + if (isset($row[$var])) { + $type = (string) $row[$var . ' type']; + $r .= $n . ' '; + $val = $this->toUTF8($row[$var]); + if (($type == '0') || ($type == 'uri')) { + $r .= $n . ' ' . $this->getSafeValue($val) . ''; + } + elseif (($type == '1') || ($type == 'bnode')) { + $r .= $n . ' ' . substr($val, 2) . ''; + } + else { + $lang_dt = ''; + foreach (array('o lang_dt', 'o lang', 'o datatype') as $k) { + if (($var == 'o') && isset($row[$k]) && $row[$k]) $lang_dt = $row[$k]; + } + $is_lang = preg_match('/^([a-z]+(\-[a-z0-9]+)*)$/i', $lang_dt); + list($lang, $dt) = $is_lang ? array($lang_dt, '') : array('', $lang_dt); + $lang = $lang ? ' xml:lang="' . $lang . '"' : ''; + $dt = $dt ? ' datatype="' . htmlspecialchars($dt) . '"' : ''; + $r .= $n . ' ' . $this->getSafeValue($val) . ''; + } + $r .= $n . ' '; + } + } + $r .= $n . ' '; + return $r; + } + + function getSafeValue($val) {/* mainly for fixing json_decode bugs */ + $mappings = array( + '%00' => '', + '%01' => '', + '%02' => '', + '%03' => '', + '%04' => '', + '%05' => '', + '%06' => '', + '%07' => '', + '%08' => '', + '%09' => '', + '%0B' => '', + '%0C' => '', + '%0E' => '', + '%0F' => '', + '%15' => '', + '%17' => 'ė', + '%1A' => ',', + '%1F' => '', + ); + $froms = array_keys($mappings); + $tos = array_values($mappings); + foreach ($froms as $i => $from) $froms[$i] = urldecode($from); + $val = str_replace($froms, $tos, $val); + if (strpos($val, '\n"; + } + else { + $val = htmlspecialchars($val); + } + return $val; + } + + function getFooter() { + $n = "\n"; + return '' . + $n . ' ' . + $n . '' . + $n . + ''; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreEndpoint.php b/arc2-2.2.4/store/ARC2_StoreEndpoint.php new file mode 100755 index 0000000..d411bac --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreEndpoint.php @@ -0,0 +1,1080 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Store'); + +class ARC2_StoreEndpoint extends ARC2_Store { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() { + parent::__init(); + $this->headers = array('http' => 'HTTP/1.1 200 OK', 'vary' => 'Vary: Accept'); + $this->read_key = $this->v('endpoint_read_key', '', $this->a); + $this->write_key = $this->v('endpoint_write_key', '', $this->a); + $this->timeout = $this->v('endpoint_timeout', 0, $this->a); + $this->a['store_allow_extension_functions'] = $this->v('store_allow_extension_functions', 0, $this->a); + $this->allow_sql = $this->v('endpoint_enable_sql_output', 0, $this->a); + $this->result = ''; + } + + /* */ + + function getQueryString($mthd = '') { + $r = ''; + if (!$mthd || ($mthd == 'post')) { + $r = @file_get_contents('php://input'); + } + $r = !$r ?$this->v1('QUERY_STRING', '', $_SERVER) : $r; + return $r; + } + + function p($name='', $mthd = '', $multi = '', $default = '') { + $mthd = strtolower($mthd); + if($multi){ + $qs = $this->getQueryString($mthd); + if (preg_match_all('/\&' . $name . '=([^\&]+)/', $qs, $m)){ + foreach ($m[1] as $i => $val) { + $m[1][$i] = stripslashes($val); + } + return $m[1]; + } + return $default ? $default : array(); + } + $args = array_merge($_GET, $_POST); + $r = isset($args[$name]) ? $args[$name] : $default; + return is_array($r) ? $r : stripslashes($r); + } + + /* */ + + function getFeatures() { + return $this->v1('endpoint_features', array(), $this->a); + } + + function setHeader($k, $v) { + $this->headers[$k] = $v; + } + + function sendHeaders() { + if (!isset($this->is_dump) || !$this->is_dump) { + $this->setHeader('content-length', 'Content-Length: ' . strlen($this->getResult())); + foreach ($this->headers as $k => $v) { + header($v); + } + } + } + + function getResult() { + return $this->result; + } + + /* */ + + function handleRequest($auto_setup = 0) { + if (!$this->isSetUp()) { + if ($auto_setup) { + $this->setUp(); + return $this->handleRequest(0); + } + else { + $this->setHeader('http', 'HTTP/1.1 400 Bad Request'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Missing configuration or the endpoint store was not set up yet.'; + } + } + elseif (($img = $this->p('img'))) { + $this->handleImgRequest($img); + } + elseif (($q = $this->p('query'))) { + $this->checkProcesses(); + $this->handleQueryRequest($q); + if ($this->p('show_inline')) { + $this->query_result = ' +
+ ' . ($this->p('output') != 'htmltab' ? '
' . htmlspecialchars($this->getResult()) . '
' : $this->getResult()) . ' +
+ '; + $this->handleEmptyRequest(1); + } + } + else { + $this->handleEmptyRequest(); + } + } + + function go($auto_setup = 0) { + $this->handleRequest($auto_setup); + $this->sendHeaders(); + echo $this->getResult(); + } + + /* */ + + function handleImgRequest($img) { + $this->setHeader('content-type', 'Content-type: image/gif'); + $imgs = array( + 'bg_body' => base64_decode('R0lGODlhAQBkAMQAAPf39/Hx8erq6vPz8/Ly8u/v7+np6fT09Ovr6/b29u3t7ejo6Pz8/Pv7+/39/fr6+vj4+P7+/vn5+f///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAABAGQAAAUp4GIIiFIExHAkAAC9cAxJdG3TT67vTe//jKBQ6Cgaj5GkcpmcOJ/QZwgAOw=='), + ); + $this->result = isset($imgs[$img]) ? $imgs[$img] : ''; + $this->sendHeaders(); + echo $this->getResult(); + exit; + } + + /* */ + + function handleEmptyRequest($force = 0) { + /* service description */ + $formats = array( + 'rdfxml' => 'RDFXML', 'rdf+xml' => 'RDFXML', 'html' => 'HTML' + ); + if (!$force && $this->getResultFormat($formats, 'html') != 'HTML') { + $this->handleServiceDescriptionRequest(); + } + else { + $this->setHeader('content-type', 'Content-type: text/html; charset=utf-8'); + $this->result = $this->getHTMLFormDoc(); + } + } + + /* */ + + function handleServiceDescriptionRequest() { + $q = ' + PREFIX void: + CONSTRUCT { + <> void:sparqlEndpoint <> . + } + WHERE { + ?s ?p ?o . + } LIMIT 1 + '; + $this->handleQueryRequest($q); + } + + /* */ + + function checkProcesses() { + if (method_exists($this->caller, 'checkSPARQLEndpointProcesses')) { + $sub_r = $this->caller->checkSPARQLEndpointProcesses(); + } + elseif ($this->timeout) { + $this->killDBProcesses('', $this->timeout); + } + } + + /* */ + + function handleQueryRequest($q) { + if (preg_match('/^dump/i', $q)) { + $infos = array('query' => array('type' => 'dump')); + $this->is_dump = 1; + } + else { + ARC2::inc('SPARQLPlusParser'); + $p = new ARC2_SPARQLPlusParser($this->a, $this); + $p->parse($q); + $infos = $p->getQueryInfos(); + } + /* errors? */ + if ($errors = $this->getErrors()) { + $this->setHeader('http', 'HTTP/1.1 400 Bad Request'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = htmlspecialchars(join("\n", $errors)); + return true; + } + $qt = $infos['query']['type']; + /* wrong read key? */ + if ($this->read_key && ($this->p('key') != $this->read_key) && preg_match('/^(select|ask|construct|describe|dump)$/', $qt)) { + $this->setHeader('http', 'HTTP/1.1 401 Access denied'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Access denied. Missing or wrong "key" parameter.'; + return true; + } + /* wrong write key? */ + if ($this->write_key && ($this->p('key') != $this->write_key) && preg_match('/^(load|insert|delete|update)$/', $qt)) { + $this->setHeader('http', 'HTTP/1.1 401 Access denied'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Access denied. Missing or wrong "key" parameter.'; + return true; + } + /* non-allowed query type? */ + if (!in_array($qt, $this->getFeatures())) { + $this->setHeader('http', 'HTTP/1.1 401 Access denied'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Access denied for "' .$qt. '" query'; + return true; + } + /* load/insert/delete via GET */ + if (in_array($qt, array('load', 'insert', 'delete')) && isset($_GET['query'])) { + $this->setHeader('http', 'HTTP/1.1 501 Not Implemented'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Query type "' .$qt. '" not supported via GET'; + return true; + } + /* unsupported query type */ + if (!in_array($qt, array('select', 'ask', 'describe', 'construct', 'load', 'insert', 'delete', 'dump'))) { + $this->setHeader('http', 'HTTP/1.1 501 Not Implemented'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Unsupported query type "' .$qt. '"'; + return true; + } + /* adjust infos */ + $infos = $this->adjustQueryInfos($infos); + $t1 = ARC2::mtime(); + $r = array('result' => $this->runQuery($infos, $qt)); + $t2 = ARC2::mtime(); + $r['query_time'] = $t2 - $t1; + /* query errors? */ + if ($errors = $this->getErrors()) { + $this->setHeader('http', 'HTTP/1.1 400 Bad Request'); + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Error: ' . join("\n", $errors); + return true; + } + /* result */ + $m = 'get' . ucfirst($qt) . 'ResultDoc'; + if (method_exists($this, $m)) { + $this->result = $this->$m($r); + } + else { + $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); + $this->result = 'Result serializer not available, dumping raw data:' . "\n" . print_r($r, 1); + } + } + + /* */ + + function adjustQueryInfos($infos) { + /* limit */ + if ($max_l = $this->v('endpoint_max_limit', 0, $this->a)) { + if ($this->v('limit', $max_l + 1, $infos['query']) > $max_l) { + $infos['query']['limit'] = $max_l; + } + } + /* default-graph-uri / named-graph-uri */ + $dgs = $this->p('default-graph-uri', '', 1); + $ngs = $this->p('named-graph-uri', '', 1); + if (count(array_merge($dgs, $ngs))) { + $ds = array(); + foreach ($dgs as $g) { + $ds[] = array('graph' => $this->calcURI($g), 'named' => 0); + } + foreach ($ngs as $g) { + $ds[] = array('graph' => $this->calcURI($g), 'named' => 1); + } + $infos['query']['dataset'] = $ds; + } + /* infos result format */ + if (($this->p('format') == 'infos') || ($this->p('output') == 'infos')) { + $infos['result_format'] = 'structure'; + } + /* sql result format */ + if (($this->p('format') == 'sql') || ($this->p('output') == 'sql')) { + $infos['result_format'] = 'sql'; + } + return $infos; + } + + /* */ + + function getResultFormat($formats, $default) { + $prefs = array(); + /* arg */ + if (($v = $this->p('format')) || ($v = $this->p('output'))) { + $prefs[] = $v; + } + /* accept header */ + $vals = explode(',', $_SERVER['HTTP_ACCEPT']); + if ($vals) { + $o_vals = array(); + foreach ($vals as $val) { + if (preg_match('/(rdf\+n3|x\-turtle|rdf\+xml|sparql\-results\+xml|sparql\-results\+json|json)/', $val, $m)) { + $o_vals[$m[1]] = 1; + if (preg_match('/\;q\=([0-9\.]+)/', $val, $sub_m)) { + $o_vals[$m[1]] = 1 * $sub_m[1]; + } + } + } + arsort($o_vals); + foreach ($o_vals as $val => $prio) { + $prefs[] = $val; + } + } + /* default */ + $prefs[] = $default; + foreach ($prefs as $pref) { + if (isset($formats[$pref])) { + return $formats[$pref]; + } + } + } + + /* SELECT */ + + function getSelectResultDoc($r) { + $formats = array( + 'xml' => 'SPARQLXML', 'sparql-results+xml' => 'SPARQLXML', + 'json' => 'SPARQLJSON', 'sparql-results+json' => 'SPARQLJSON', + 'php_ser' => 'PHPSER', 'plain' => 'Plain', + 'sql' => ($this->allow_sql ? 'Plain' : 'xSQL'), + 'infos' => 'Plain', + 'htmltab' => 'HTMLTable', + 'tsv' => 'TSV', + ); + if ($f = $this->getResultFormat($formats, 'xml')) { + $m = 'get' . $f . 'SelectResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getSPARQLXMLSelectResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+xml'); + $vars = $r['result']['variables']; + $rows = $r['result']['rows']; + $dur = $r['query_time']; + $nl = "\n"; + /* doc */ + $r = '' . + '' . + $nl . '' . + ''; + /* head */ + $r .= $nl . ' '; + $r .= $nl . ' '; + if (is_array($vars)) { + foreach ($vars as $var) { + $r .= $nl . ' '; + } + } + $r .= $nl . ' '; + /* results */ + $r .= $nl . ' '; + if (is_array($rows)) { + foreach ($rows as $row) { + $r .= $nl . ' '; + foreach ($vars as $var) { + if (isset($row[$var])) { + $r .= $nl . ' '; + if ($row[$var . ' type'] == 'uri') { + $r .= $nl . ' ' .htmlspecialchars($row[$var]). ''; + } + elseif ($row[$var . ' type'] == 'bnode') { + $r .= $nl . ' ' .substr($row[$var], 2). ''; + } + else { + $dt = isset($row[$var . ' datatype']) ? ' datatype="' .htmlspecialchars($row[$var . ' datatype']). '"' : ''; + $lang = isset($row[$var . ' lang']) ? ' xml:lang="' .htmlspecialchars($row[$var . ' lang']). '"' : ''; + $r .= $nl . ' ' .htmlspecialchars($row[$var]). ''; + } + $r .= $nl . ' '; + } + } + $r .= $nl . ' '; + } + } + $r .= $nl . ' '; + /* /doc */ + $r .= $nl . ''; + return $r; + } + + function getSPARQLJSONSelectResultDoc($r) { + $con = $this->getDBCon(); + $this->setHeader('content-type', 'Content-Type: application/sparql-results+json'); + $vars = $r['result']['variables']; + $rows = $r['result']['rows']; + $dur = $r['query_time']; + $nl = "\n"; + /* doc */ + $r = '{'; + /* head */ + $r .= $nl . ' "head": {'; + $r .= $nl . ' "vars": ['; + $first_var = 1; + foreach ($vars as $var) { + $r .= $first_var ? $nl : ',' . $nl; + $r .= ' "' .$var. '"'; + $first_var = 0; + } + $r .= $nl . ' ]'; + $r .= $nl . ' },'; + /* results */ + $r .= $nl . ' "results": {'; + $r .= $nl . ' "bindings": ['; + $first_row = 1; + foreach ($rows as $row) { + $r .= $first_row ? $nl : ',' . $nl; + $r .= ' {'; + $first_var = 1; + foreach ($vars as $var) { + if (isset($row[$var])) { + $r .= $first_var ? $nl : ',' . $nl . $nl; + $r .= ' "' .$var. '": {'; + if ($row[$var . ' type'] == 'uri') { + $r .= $nl . ' "type": "uri",'; + $r .= $nl . ' "value": "' .mysql_real_escape_string($row[$var], $con). '"'; + } + elseif ($row[$var . ' type'] == 'bnode') { + $r .= $nl . ' "type": "bnode",'; + $r .= $nl . ' "value": "' . substr($row[$var], 2) . '"'; + } + else { + $dt = isset($row[$var . ' datatype']) ? ',' . $nl .' "datatype": "' .mysql_real_escape_string($row[$var . ' datatype'], $con). '"' : ''; + $lang = isset($row[$var . ' lang']) ? ',' . $nl .' "xml:lang": "' .mysql_real_escape_string($row[$var . ' lang'], $con). '"' : ''; + $type = $dt ? 'typed-literal' : 'literal'; + $r .= $nl . ' "type": "' . $type . '",'; + $r .= $nl . ' "value": "' . $this->jsonEscape($row[$var]) . '"'; + $r .= $dt . $lang; + } + $r .= $nl . ' }'; + $first_var = 0; + } + } + $r .= $nl . ' }'; + $first_row = 0; + } + $r .= $nl . ' ]'; + $r .= $nl . ' }'; + /* /doc */ + $r .= $nl . '}'; + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERSelectResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainSelectResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return print_r($r['result'], 1); + } + + function getHTMLTableSelectResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/html; charset=utf-8'); + $vars = $r['result']['variables']; + $rows = $r['result']['rows']; + $dur = $r['query_time']; + if ($this->p('show_inline')) return '' . $this->getHTMLTableRows($rows, $vars) . '
'; + return ' + + ' .$this->getHTMLDocHead() . ' + + + ' . $this->getHTMLTableRows($rows, $vars) . ' +
+ + + '; + } + + function getHTMLTableRows($rows, $vars) { + $r = ''; + foreach ($rows as $row) { + $hr = ''; + $rr = ''; + foreach ($vars as $var) { + $hr .= $r ? '' : '' . htmlspecialchars($var) . ''; + $rr .= '' . @htmlspecialchars($row[$var]) . ''; + } + $r .= $hr ? '' . $hr . '' : ''; + $r .= '' . $rr . ''; + } + return $r ? $r : 'No results found'; + } + + function getTSVSelectResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain; charset=utf-8'); + $vars = $r['result']['variables']; + $rows = $r['result']['rows']; + $dur = $r['query_time']; + return $this->getTSVRows($rows, $vars); + } + + function getTSVRows($rows, $vars) { + $r = ''; + $delim = "\t"; + $esc_delim = "\\t"; + foreach ($rows as $row) { + $hr = ''; + $rr = ''; + foreach ($vars as $var) { + $hr .= $r ? '' : ($hr ? $delim . $var : $var); + $val = isset($row[$var]) ? str_replace($delim, $esc_delim, $row[$var]) : ''; + $rr .= $rr ? $delim . $val : $val; + } + $r .= $hr . "\n" . $rr; + } + return $r ? $r : 'No results found'; + } + + /* ASK */ + + function getAskResultDoc($r) { + $formats = array( + 'xml' => 'SPARQLXML', 'sparql-results+xml' => 'SPARQLXML', + 'json' => 'SPARQLJSON', 'sparql-results+json' => 'SPARQLJSON', + 'plain' => 'Plain', + 'php_ser' => 'PHPSER', + 'sql' => ($this->allow_sql ? 'Plain' : 'xSQL'), + 'infos' => 'Plain', + ); + if ($f = $this->getResultFormat($formats, 'xml')) { + $m = 'get' . $f . 'AskResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getSPARQLXMLAskResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+xml'); + $r_val = $r['result'] ? 'true' : 'false'; + $dur = $r['query_time']; + $nl = "\n"; + return '' . + '' . + $nl . '' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' .$r_val. '' . + $nl . '' . + ''; + } + + function getSPARQLJSONAskResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+json'); + $r_val = $r['result'] ? 'true' : 'false'; + $dur = $r['query_time']; + $nl = "\n"; + $r = '' . + $nl . '{' . + $nl . ' "head": {' . + $nl . ' },' . + $nl . ' "boolean" : ' . $r_val . + $nl . '}' . + ''; + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERAskResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainAskResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return $r['result'] ? 'true' : 'false'; + } + + /* CONSTRUCT */ + + function getConstructResultDoc($r) { + $formats = array( + 'rdfxml' => 'RDFXML', 'rdf+xml' => 'RDFXML', + 'json' => 'RDFJSON', 'rdf+json' => 'RDFJSON', + 'turtle' => 'Turtle', 'x-turtle' => 'Turtle', 'rdf+n3' => 'Turtle', + 'php_ser' => 'PHPSER', + 'sql' => ($this->allow_sql ? 'Plain' : 'xSQL'), + 'infos' => 'Plain', + ); + if ($f = $this->getResultFormat($formats, 'rdfxml')) { + $m = 'get' . $f . 'ConstructResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getRDFXMLConstructResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/rdf+xml'); + $index = $r['result']; + $ser = ARC2::getRDFXMLSerializer($this->a); + $dur = $r['query_time']; + return $ser->getSerializedIndex($index) . "\n" . ''; + } + + function getTurtleConstructResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/x-turtle'); + $index = $r['result']; + $ser = ARC2::getTurtleSerializer($this->a); + $dur = $r['query_time']; + return '# query time: ' . $dur . "\n" . $ser->getSerializedIndex($index); + } + + function getRDFJSONConstructResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/json'); + $index = $r['result']; + $ser = ARC2::getRDFJSONSerializer($this->a); + $dur = $r['query_time']; + $r = $ser->getSerializedIndex($index); + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERConstructResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainConstructResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return print_r($r['result'], 1); + } + + /* DESCRIBE */ + + function getDescribeResultDoc($r) { + $formats = array( + 'rdfxml' => 'RDFXML', 'rdf+xml' => 'RDFXML', + 'json' => 'RDFJSON', 'rdf+json' => 'RDFJSON', + 'turtle' => 'Turtle', 'x-turtle' => 'Turtle', 'rdf+n3' => 'Turtle', + 'php_ser' => 'PHPSER', + 'sql' => ($this->allow_sql ? 'Plain' : 'xSQL'), + 'infos' => 'Plain' + ); + if ($f = $this->getResultFormat($formats, 'rdfxml')) { + $m = 'get' . $f . 'DescribeResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getRDFXMLDescribeResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/rdf+xml'); + $index = $r['result']; + $ser = ARC2::getRDFXMLSerializer($this->a); + $dur = $r['query_time']; + return $ser->getSerializedIndex($index) . "\n" . ''; + } + + function getTurtleDescribeResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/x-turtle'); + $index = $r['result']; + $ser = ARC2::getTurtleSerializer($this->a); + $dur = $r['query_time']; + return '# query time: ' . $dur . "\n" . $ser->getSerializedIndex($index); + } + + function getRDFJSONDescribeResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/json'); + $index = $r['result']; + $ser = ARC2::getRDFJSONSerializer($this->a); + $dur = $r['query_time']; + $r = $ser->getSerializedIndex($index); + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERDescribeResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainDescribeResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return print_r($r['result'], 1); + } + + /* DUMP */ + + function getDumpResultDoc() { + $this->headers = array(); + return ''; + } + + /* LOAD */ + + function getLoadResultDoc($r) { + $formats = array( + 'xml' => 'SPARQLXML', 'sparql-results+xml' => 'SPARQLXML', + 'json' => 'SPARQLJSON', 'sparql-results+json' => 'SPARQLJSON', + 'plain' => 'Plain', + 'php_ser' => 'PHPSER', + 'sql' => ($this->allow_sql ? 'Plain' : 'xSQL'), + 'infos' => 'Plain', + ); + if ($f = $this->getResultFormat($formats, 'xml')) { + $m = 'get' . $f . 'LoadResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getSPARQLXMLLoadResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+xml'); + $r_val = $r['result']['t_count']; + $dur = $r['query_time']; + $nl = "\n"; + return '' . + '' . + $nl . '' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' .$r_val. '' . + $nl . '' . + ''; + } + + function getSPARQLJSONLoadResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+json'); + $r_val = $r['result']['t_count']; + $dur = $r['query_time']; + $nl = "\n"; + $r = '' . + $nl . '{' . + $nl . ' "head": {' . + $nl . ' },' . + $nl . ' "inserted" : ' . $r_val . + $nl . '}' . + ''; + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERLoadResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainLoadResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return print_r($r['result'], 1); + } + + /* DELETE */ + + function getDeleteResultDoc($r) { + $formats = array( + 'xml' => 'SPARQLXML', 'sparql-results+xml' => 'SPARQLXML', + 'json' => 'SPARQLJSON', 'sparql-results+json' => 'SPARQLJSON', + 'plain' => 'Plain', + 'php_ser' => 'PHPSER' + ); + if ($f = $this->getResultFormat($formats, 'xml')) { + $m = 'get' . $f . 'DeleteResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getSPARQLXMLDeleteResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+xml'); + $r_val = $r['result']['t_count']; + $dur = $r['query_time']; + $nl = "\n"; + return '' . + '' . + $nl . '' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' .$r_val. '' . + $nl . '' . + ''; + } + + function getSPARQLJSONDeleteResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+json'); + $r_val = $r['result']['t_count']; + $dur = $r['query_time']; + $nl = "\n"; + $r = '' . + $nl . '{' . + $nl . ' "head": {' . + $nl . ' },' . + $nl . ' "deleted" : ' . $r_val . + $nl . '}' . + ''; + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERDeleteResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainDeleteResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return print_r($r['result'], 1); + } + + /* INSERT */ + + function getInsertResultDoc($r) { + $formats = array( + 'xml' => 'SPARQLXML', 'sparql-results+xml' => 'SPARQLXML', + 'json' => 'SPARQLJSON', 'sparql-results+json' => 'SPARQLJSON', + 'plain' => 'Plain', + 'php_ser' => 'PHPSER' + ); + if ($f = $this->getResultFormat($formats, 'xml')) { + $m = 'get' . $f . 'InsertResultDoc'; + return method_exists($this, $m) ? $this->$m($r) : 'not implemented'; + } + return ''; + } + + function getSPARQLXMLInsertResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+xml'); + $r_val = $r['result']['t_count']; + $dur = $r['query_time']; + $nl = "\n"; + return '' . + '' . + $nl . '' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' . + $nl . ' ' .$r_val. '' . + $nl . '' . + ''; + } + + function getSPARQLJSONInsertResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: application/sparql-results+json'); + $r_val = $r['result']['t_count']; + $dur = $r['query_time']; + $nl = "\n"; + $r = '' . + $nl . '{' . + $nl . ' "head": {' . + $nl . ' },' . + $nl . ' "inserted" : ' . $r_val . + $nl . '}' . + ''; + if (($v = $this->p('jsonp')) || ($v = $this->p('callback'))) { + $r = $v . '(' . $r . ')'; + } + return $r; + } + + function getPHPSERInsertResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return serialize($r); + } + + function getPlainInsertResultDoc($r) { + $this->setHeader('content-type', 'Content-Type: text/plain'); + return print_r($r['result'], 1); + } + + /* */ + + function jsonEscape($v) { + if (function_exists('json_encode')) return trim(json_encode($v), '"'); + $from = array("\\", "\r", "\t", "\n", '"', "\b", "\f", "/"); + $to = array('\\\\', '\r', '\t', '\n', '\"', '\b', '\f', '\/'); + return str_replace($from, $to, $v); + } + + /* */ + + function getHTMLFormDoc() { + return ' + + ' . $this->getHTMLDocHead() . ' + ' . $this->getHTMLDocBody() . ' + + '; + } + + function getHTMLDocHead() { + return ' + + ' . $this->getHTMLDocTitle() . ' + + + '; + } + + function getHTMLDocTitle() { + return $this->v('endpoint_title', 'ARC SPARQL+ Endpoint', $this->a); + } + + function getHTMLDocHeading() { + return $this->v('endpoint_heading', 'ARC SPARQL+ Endpoint (v' . ARC2::getVersion() . ')', $this->a); + } + + function getHTMLDocCSS() { + $default = ' + body { + font-size: 14px; + font-family: Trebuchet MS, Verdana, Geneva, sans-serif; + background: #fff url(?img=bg_body) top center repeat-x; + padding: 5px 20px 20px 20px; + color: #666; + } + h1 { font-size: 1.6em; font-weight: normal; } + a { color: #c00000; } + th, td { + border: 1px dotted #eee; + padding: 2px 4px; + } + #sparql-form { + margin-bottom: 30px; + } + #query { + float: left; + width: 60%; + display: block; + height: 265px; + margin-bottom: 10px; + } + .options { + float: right; + font-size: 0.9em; + width: 35%; + border-top: 1px solid #ccc; + } + .options h3 { + margin: 5px; + } + .options dl{ + margin: 0px; + padding: 0px 10px 5px 20px; + } + .options dl dt { + border-top: 1px dotted #ddd; + padding-top: 10px; + } + .options dl dt.first { + border: none; + } + .options dl dd { + padding: 5px 0px 7px 0px; + } + .options-2 { + clear: both; + margin: 10px 0px; + } + .form-buttons { + } + .results { + border: 1px solid #eee; + padding: 5px; + background-color: #fcfcfc; + } + '; + return $this->v('endpoint_css', $default, $this->a); + } + + function getHTMLDocBody() { + return ' + +

' . $this->getHTMLDocHeading() . '

+
+

+ This interface implements + SPARQL and + SPARQL+ via HTTP Bindings. +

+

+ Enabled operations: ' . join(', ', $this->getFeatures()) . ' +

+

+ Max. number of results : ' . $this->v('endpoint_max_limit', 'unrestricted', $this->a) . ' +

+
+ ' . $this->getHTMLDocForm() .' + ' . ($this->p('show_inline') ? $this->query_result : '') . ' + + '; + } + + function getHTMLDocForm() { + $q = $this->p('query') ? htmlspecialchars($this->p('query')) : "SELECT * WHERE {\n GRAPH ?g { ?s ?p ?o . }\n}\nLIMIT 10"; + return ' +
+ + ' . $this->getHTMLDocOptions() . ' +
+ + +
+
+ '; + } + + function getHTMLDocOptions() { + $sel = $this->p('output'); + $sel_code = ' selected="selected"'; + return ' +
+

Options

+
+
Output format (if supported by query type):
+
+ +
+ +
jsonp/callback (for JSON results)
+
+ +
+ +
API key (if required)
+
+ +
+ +
Show results inline:
+
+ p('show_inline') ? ' checked="checked"' : '') . ' /> +
+ +
+
+
+ Change HTTP method: + GET + POST +
+ '; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreHelper.php b/arc2-2.2.4/store/ARC2_StoreHelper.php new file mode 100755 index 0000000..9ce9c58 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreHelper.php @@ -0,0 +1,66 @@ +store = $this->caller; + } + + /* */ + + function changeNamespaceURI($old_uri, $new_uri) { + $id_changes = 0; + $t_changes = 0; + /* table lock */ + if ($this->store->getLock()) { + $con = $this->store->getDBCon(); + foreach (array('id', 's', 'o') as $id_col) { + $tbl = $this->store->getTablePrefix() . $id_col . '2val'; + $sql = 'SELECT id, val FROM ' . $tbl . ' WHERE val LIKE "' . mysql_real_escape_string($old_uri, $con). '%"'; + $rs = mysql_query($sql, $con); + if (!$rs) continue; + while ($row = mysql_fetch_array($rs)) { + $new_val = str_replace($old_uri, $new_uri, $row['val']); + $new_id = $this->store->getTermID($new_val, $id_col); + if (!$new_id) {/* unknown ns uri, overwrite current id value */ + $sub_sql = "UPDATE " . $tbl . " SET val = '" . mysql_real_escape_string($new_val, $con) . "' WHERE id = " . $row['id']; + $sub_r = mysql_query($sub_sql, $con); + $id_changes++; + } + else {/* replace ids */ + $t_tbls = $this->store->getTables(); + foreach ($t_tbls as $t_tbl) { + if (preg_match('/^triple/', $t_tbl)) { + foreach (array('s', 'p', 'o', 'o_lang_dt') as $t_col) { + $sub_sql = "UPDATE " . $this->store->getTablePrefix() . $t_tbl . " SET " . $t_col . " = " . $new_id . " WHERE " . $t_col . " = " . $row['id']; + $sub_r = mysql_query($sub_sql, $con); + $t_changes += mysql_affected_rows($con); + } + } + } + } + } + } + $this->store->releaseLock(); + } + return array('id_replacements' => $id_changes, 'triple_updates' => $t_changes); + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreInsertQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreInsertQueryHandler.php new file mode 100755 index 0000000..bffdab5 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreInsertQueryHandler.php @@ -0,0 +1,54 @@ + + * @license http://arc.semsol.org/license + * @homepage + * @package ARC2 +*/ + +ARC2::inc('StoreQueryHandler'); + +class ARC2_StoreInsertQueryHandler extends ARC2_StoreQueryHandler { + + function __construct($a, &$caller) {/* caller has to be a store */ + parent::__construct($a, $caller); + } + + function __init() {/* db_con */ + parent::__init(); + $this->store = $this->caller; + } + + /* */ + + function runQuery($infos, $keep_bnode_ids = 0) { + $this->infos = $infos; + $con = $this->store->getDBCon(); + /* insert */ + if (!$this->v('pattern', array(), $this->infos['query'])) { + $triples = $this->infos['query']['construct_triples']; + /* don't execute empty INSERTs as they trigger a LOAD on the graph URI */ + if ($triples) { + return $this->store->insert($triples, $this->infos['query']['target_graph'], $keep_bnode_ids); + } + else { + return array('t_count' => 0, 'load_time' => 0); + } + } + else { + $keep_bnode_ids = 1; + ARC2::inc('StoreConstructQueryHandler'); + $h = new ARC2_StoreConstructQueryHandler($this->a, $this->store); + $sub_r = $h->runQuery($this->infos); + if ($sub_r) { + return $this->store->insert($sub_r, $this->infos['query']['target_graph'], $keep_bnode_ids); + } + return array('t_count' => 0, 'load_time' => 0); + } + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreLoadQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreLoadQueryHandler.php new file mode 100755 index 0000000..621ccd7 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreLoadQueryHandler.php @@ -0,0 +1,464 @@ + + * @homepage + * @package ARC2 +*/ + +ARC2::inc('StoreQueryHandler'); + +class ARC2_StoreLoadQueryHandler extends ARC2_StoreQueryHandler { + + function __construct($a, &$caller) {/* caller has to be a store */ + parent::__construct($a, $caller); + } + + function __init() {/* db_con, store_log_inserts */ + parent::__init(); + $this->store = $this->caller; + $this->write_buffer_size = $this->v('store_write_buffer', 2500, $this->a); + $this->split_threshold = $this->v('store_split_threshold', 0, $this->a); + $this->strip_mb_comp_str = $this->v('store_strip_mb_comp_str', 0, $this->a); + } + + /* */ + + function runQuery($infos, $data = '', $keep_bnode_ids = 0) { + $url = $infos['query']['url']; + $graph = $infos['query']['target_graph']; + $this->target_graph = $graph ? $this->calcURI($graph) : $this->calcURI($url); + $this->fixed_target_graph = $graph ? $this->target_graph : ''; + $this->keep_bnode_ids = $keep_bnode_ids; + /* reader */ + ARC2::inc('Reader'); + $reader = new ARC2_Reader($this->a, $this); + $reader->activate($url, $data); + /* format detection */ + $mappings = array( + 'rdfxml' => 'RDFXML', + 'sparqlxml' => 'SPOG', + 'turtle' => 'Turtle', + 'ntriples' => 'Turtle', + 'rss' => 'RSS', + 'atom' => 'Atom', + 'n3' => 'Turtle', + 'html' => 'SemHTML', + 'sgajson' => 'SGAJSON', + 'cbjson' => 'CBJSON' + ); + $format = $reader->getFormat(); + if (!$format || !isset($mappings[$format])) { + return $this->addError('No loader available for "' .$url. '": ' . $format); + } + /* format loader */ + $suffix = 'Store' . $mappings[$format] . 'Loader'; + ARC2::inc($suffix); + $cls = 'ARC2_' . $suffix; + $loader = new $cls($this->a, $this); + $loader->setReader($reader); + /* lock */ + if (!$this->store->getLock()) { + $l_name = $this->a['db_name'] . '.' . $this->store->getTablePrefix() . '.write_lock'; + return $this->addError('Could not get lock in "runQuery" (' . $l_name . ')'); + } + $this->has_lock = 1; + /* logging */ + $this->t_count = 0; + $this->t_start = ARC2::mtime(); + $this->log_inserts = $this->v('store_log_inserts', 0, $this->a); + if ($this->log_inserts) { + @unlink("arc_insert_log.txt"); + $this->inserts = array(); + $this->insert_times = array(); + $this->t_prev = $this->t_start; + $this->t_count_prev = 0 ; + } + /* load and parse */ + $this->max_term_id = $this->getMaxTermID(); + $this->max_triple_id = $this->getMaxTripleID(); + $this->column_type = $this->store->getColumnType(); + //$this->createMergeTable(); + $this->term_ids = array(); + $this->triple_ids = array(); + $this->sql_buffers = array(); + $r = $loader->parse($url, $data); + /* done */ + $this->checkSQLBuffers(1); + if ($this->log_inserts) { + $this->logInserts(); + } + $this->store->releaseLock(); + //$this->dropMergeTable(); + if ((rand(1, 100) == 1)) $this->store->optimizeTables(); + $t2 = ARC2::mtime(); + $dur = round($t2 - $this->t_start, 4); + $r = array( + 't_count' => $this->t_count, + 'load_time' => $dur, + ); + if ($this->log_inserts) { + $r['inserts'] = $this->inserts; + $r['insert_times'] = $this->insert_times; + } + return $r; + } + + /* */ + + function addT($s, $p, $o, $s_type, $o_type, $o_dt = '', $o_lang = '') { + if (!$this->has_lock) return 0; + $type_ids = array ('uri' => '0', 'bnode' => '1' , 'literal' => '2'); + $g = $this->getStoredTermID($this->target_graph, '0', 'id'); + $s = (($s_type == 'bnode') && !$this->keep_bnode_ids) ? '_:b' . abs(crc32($g . $s)) . '_' . (strlen($s) > 12 ? substr(substr($s, 2) , -10) : substr($s, 2)) : $s; + $o = (($o_type == 'bnode') && !$this->keep_bnode_ids) ? '_:b' . abs(crc32($g . $o)) . '_' . (strlen($o) > 12 ? substr(substr($o, 2), -10) : substr($o, 2)) : $o; + /* triple */ + $t = array( + 's' => $this->getStoredTermID($s, $type_ids[$s_type], 's'), + 'p' => $this->getStoredTermID($p, '0', 'id'), + 'o' => $this->getStoredTermID($o, $type_ids[$o_type], 'o'), + 'o_lang_dt' => $this->getStoredTermID($o_dt . $o_lang, $o_dt ? '0' : '2', 'id'), + 'o_comp' => $this->getOComp($o), + 's_type' => $type_ids[$s_type], + 'o_type' => $type_ids[$o_type], + ); + $t['t'] = $this->getTripleID($t); + if (is_array($t['t'])) {/* t exists already */ + $t['t'] = $t['t'][0]; + } + else { + $this->bufferTripleSQL($t); + } + /* g2t */ + $g2t = array('g' => $g, 't' => $t['t']); + $this->bufferGraphSQL($g2t); + $this->t_count++; + /* check buffers */ + if (($this->t_count % $this->write_buffer_size) == 0) { + $force_write = 1; + $reset_buffers = (($this->t_count % ($this->write_buffer_size * 2)) == 0); + $refresh_lock = (($this->t_count % 25000) == 0); + $split_tables = (($this->t_count % ($this->write_buffer_size * 10)) == 0); + if ($this->log_inserts) $this->logInserts(); + $this->checkSQLBuffers($force_write, $reset_buffers, $refresh_lock, $split_tables); + } + } + + /* */ + + function getMaxTermID() { + $con = $this->store->getDBCon(); + $sql = ''; + foreach (array('id2val', 's2val', 'o2val') as $tbl) { + $sql .= $sql ? ' UNION ' : ''; + $sql .= "(SELECT MAX(id) as `id` FROM " . $this->store->getTablePrefix() . $tbl . ')'; + } + $r = 0; + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs)) { + while ($row = mysql_fetch_array($rs)) { + $r = ($r < $row['id']) ? $row['id'] : $r; + } + } + return $r + 1; + } + + function getMaxTripleID() { + $con = $this->store->getDBCon(); + $sql = "SELECT MAX(t) AS `id` FROM " . $this->store->getTablePrefix() . "triple"; + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs) && ($row = mysql_fetch_array($rs))) { + return $row['id'] + 1; + } + return 1; + } + + function getStoredTermID($val, $type_id, $tbl) { + $con = $this->store->getDBCon(); + /* buffered */ + if (isset($this->term_ids[$val])) { + if (!isset($this->term_ids[$val][$tbl])) { + foreach (array('id', 's', 'o') as $other_tbl) { + if (isset($this->term_ids[$val][$other_tbl])) { + $this->term_ids[$val][$tbl] = $this->term_ids[$val][$other_tbl]; + $this->bufferIDSQL($tbl, $this->term_ids[$val][$tbl], $val, $type_id); + break; + } + } + } + return $this->term_ids[$val][$tbl]; + } + /* db */ + $tbl_prefix = $this->store->getTablePrefix(); + $sub_tbls = ($tbl == 'id') ? array('id2val', 's2val', 'o2val') : ($tbl == 's' ? array('s2val', 'id2val', 'o2val') : array('o2val', 'id2val', 's2val')); + foreach ($sub_tbls as $sub_tbl) { + $id = 0; + //$sql = "SELECT id AS `id`, '" . $sub_tbl . "' AS `tbl` FROM " . $tbl_prefix . $sub_tbl . " WHERE val = BINARY '" . mysql_real_escape_string($val, $con) . "'"; + /* via hash */ + if (preg_match('/^(s2val|o2val)$/', $sub_tbl) && $this->hasHashColumn($sub_tbl)) { + $sql = "SELECT id AS `id`, val AS `val` FROM " . $tbl_prefix . $sub_tbl . " WHERE val_hash = BINARY '" . $this->getValueHash($val) . "'"; + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs)) { + while ($row = mysql_fetch_array($rs)) { + if ($row['val'] == $val) { + $id = $row['id']; + break; + } + } + } + } + else { + $sql = "SELECT id AS `id` FROM " . $tbl_prefix . $sub_tbl . " WHERE val = BINARY '" . mysql_real_escape_string($val, $con) . "'"; + if (($rs = $this->queryDB($sql . ' LIMIT 1', $con)) && mysql_num_rows($rs)) { + $row = mysql_fetch_array($rs); + $id = $row['id']; + } + } + if ($id) { + $this->term_ids[$val] = array($tbl => $id); + if ($sub_tbl != $tbl . '2val') { + $this->bufferIDSQL($tbl, $id, $val, $type_id); + } + break; + } + } + /* new */ + if (!isset($this->term_ids[$val])) { + $this->term_ids[$val] = array($tbl => $this->max_term_id); + $this->bufferIDSQL($tbl, $this->max_term_id, $val, $type_id); + $this->max_term_id++; + /* upgrade tables ? */ + if (($this->column_type == 'mediumint') && ($this->max_term_id >= 16750000)) { + $this->store->extendColumns(); + $this->column_type = 'int'; + } + } + return $this->term_ids[$val][$tbl]; + } + + function getTripleID($t) { + $con = $this->store->getDBCon(); + $val = serialize($t); + /* buffered */ + if (isset($this->triple_ids[$val])) { + return array($this->triple_ids[$val]);/* hack for "don't insert this triple" */ + } + /* db */ + $sql = "SELECT t FROM " . $this->store->getTablePrefix() . "triple WHERE + s = " . $t['s'] . " AND p = " . $t['p'] . " AND o = " . $t['o'] . " AND o_lang_dt = " . $t['o_lang_dt'] . " AND s_type = " . $t['s_type'] . " AND o_type = " . $t['o_type'] . " + LIMIT 1 + "; + if (($rs = $this->queryDB($sql, $con)) && mysql_num_rows($rs) && ($row = mysql_fetch_array($rs))) { + $this->triple_ids[$val] = $row['t'];/* hack for "don't insert this triple" */ + return array($row['t']);/* hack for "don't insert this triple" */ + } + /* new */ + else { + $this->triple_ids[$val] = $this->max_triple_id; + $this->max_triple_id++; + /* split tables ? */ + if (0 && $this->split_threshold && !($this->max_triple_id % $this->split_threshold)) { + $this->store->splitTables(); + $this->dropMergeTable(); + $this->createMergeTable(); + } + /* upgrade tables ? // Thanks to patch by Mark Fichtner (https://github.com/Knurg) */ + if (($this->column_type == 'mediumint') && ($this->max_triple_id >= 16750000)) { + $this->store->extendColumns(); + $this->column_type = 'int'; + } + return $this->triple_ids[$val]; + } + } + + function getOComp($val) { + /* try date (e.g. 21 August 2007) */ + if (preg_match('/^[0-9]{1,2}\s+[a-z]+\s+[0-9]{4}/i', $val) && ($uts = strtotime($val)) && ($uts !== -1)) { + return date("Y-m-d\TH:i:s", $uts); + } + /* xsd date (e.g. 2009-05-28T18:03:38+09:00 2009-05-28T18:03:38GMT) */ + if (preg_match('/^([0-9]{4}\-[0-9]{2}\-[0-9]{2}\T)([0-9\:]+)?([0-9\+\-\:\Z]+)?(\s*[a-z]{2,3})?$/si', $val, $m)) { + /* yyyy-mm-dd */ + $val = $m[1]; + /* hh:ss */ + if ($m[2]) { + $val .= $m[2]; + /* timezone offset */ + if (isset($m[3]) && ($m[3] != 'Z')) { + $uts = strtotime(str_replace('T', ' ', $val)); + if (preg_match('/([\+\-])([0-9]{2})\:?([0-9]{2})$/', $m[3], $sub_m)) { + $diff_mins = (3600 * ltrim($sub_m[2], '0')) + ltrim($sub_m[3], '0'); + $uts = ($sub_m[1] == '-') ? $uts + $diff_mins : $uts - $diff_mins; + $val = date('Y-m-d\TH:i:s\Z', $uts); + } + } + else { + $val .= 'Z'; + } + } + return $val; + } + /* fallback & backup w/o UTC calculation, to be removed in later revision */ + if (preg_match('/^[0-9]{4}[0-9\-\:\T\Z\+]+([a-z]{2,3})?$/i', $val)) { + return $val; + } + if (is_numeric($val)) { + $val = sprintf("%f", $val); + if (preg_match("/([\-\+])([0-9]*)\.([0-9]*)/", $val, $m)) { + return $m[1] . sprintf("%018s", $m[2]) . "." . sprintf("%-015s", $m[3]); + } + if (preg_match("/([0-9]*)\.([0-9]*)/", $val, $m)) { + return "+" . sprintf("%018s", $m[1]) . "." . sprintf("%-015s", $m[2]); + } + return $val; + } + /* any other string: remove tags, linebreaks etc., but keep MB-chars */ + //$val = substr(trim(preg_replace('/[\W\s]+/is', '-', strip_tags($val))), 0, 35); + // [\PL\s]+ ( = non-Letters) kills digits + $re = $this->has_pcre_unicode ? '/[\PL\s]+/isu' : '/[\s\'\"\´\`]+/is'; + $re = '/[\s\'\"\´\`]+/is'; + $val = trim(preg_replace($re, '-', strip_tags($val))); + if (strlen($val) > 35) { + $fnc = function_exists("mb_substr") ? 'mb_substr' : 'substr'; + $val = $fnc($val, 0, 17) . '-' . $fnc($val, -17); + } + if ($this->strip_mb_comp_str) { + $val = urldecode(preg_replace('/\%[0-9A-F]{2}/', '', urlencode($val))); + } + return $this->toUTF8($val); + } + + /* */ + + function bufferTripleSQL($t) { + $con = $this->store->getDBCon(); + $tbl = 'triple'; + $sql = ", "; + if (!isset($this->sql_buffers[$tbl])) { + $this->sql_buffers[$tbl] = "INSERT IGNORE INTO " . $this->store->getTablePrefix() . $tbl . " (t, s, p, o, o_lang_dt, o_comp, s_type, o_type) VALUES"; + $sql = " "; + } + $this->sql_buffers[$tbl] .= $sql . "(" . $t['t'] . ", " . $t['s'] . ", " . $t['p'] . ", " . $t['o'] . ", " . $t['o_lang_dt'] . ", '" . mysql_real_escape_string($t['o_comp'], $con) . "', " . $t['s_type'] . ", " . $t['o_type'] . ")"; + } + + function bufferGraphSQL($g2t) { + $tbl = 'g2t'; + $sql = ", "; + if (!isset($this->sql_buffers[$tbl])) { + $this->sql_buffers[$tbl] = "INSERT IGNORE INTO " . $this->store->getTablePrefix() . $tbl . " (g, t) VALUES"; + $sql = " "; + } + $this->sql_buffers[$tbl] .= $sql . "(" . $g2t['g'] . ", " . $g2t['t'] . ")"; + } + + function bufferIDSQL($tbl, $id, $val, $val_type) { + $con = $this->store->getDBCon(); + $tbl = $tbl . '2val'; + if ($tbl == 'id2val') { + $cols = "id, val, val_type"; + $vals = "(" . $id . ", '" . mysql_real_escape_string($val, $con) . "', " . $val_type . ")"; + } + elseif (preg_match('/^(s2val|o2val)$/', $tbl) && $this->hasHashColumn($tbl)) { + $cols = "id, val_hash, val"; + $vals = "(" . $id . ", '" . $this->getValueHash($val). "', '" . mysql_real_escape_string($val, $con) . "')"; + } + else { + $cols = "id, val"; + $vals = "(" . $id . ", '" . mysql_real_escape_string($val, $con) . "')"; + } + if (!isset($this->sql_buffers[$tbl])) { + $this->sql_buffers[$tbl] = ''; + $sql = "INSERT IGNORE INTO " . $this->store->getTablePrefix() . $tbl . "(" . $cols . ") VALUES "; + } + else { + $sql = ", "; + } + $sql .= $vals; + $this->sql_buffers[$tbl] .= $sql; + } + + /* */ + + function checkSQLBuffers($force_write = 0, $reset_id_buffers = 0, $refresh_lock = 0, $split_tables = 0) { + $con = $this->store->getDBCon(); + if (!$this->keep_time_limit) @set_time_limit($this->v('time_limit', 60, $this->a)); + foreach (array('triple', 'g2t', 'id2val', 's2val', 'o2val') as $tbl) { + $buffer_size = isset($this->sql_buffers[$tbl]) ? 1 : 0; + if ($buffer_size && $force_write) { + $t1 = ARC2::mtime(); + $this->queryDB($this->sql_buffers[$tbl], $con); + /* table error */ + if ($er = mysql_error($con)) { + $this->autoRepairTable($er, $con, $this->sql_buffers[$tbl]); + } + unset($this->sql_buffers[$tbl]); + if ($this->log_inserts) { + $t2 = ARC2::mtime(); + $this->inserts[$tbl] = $this->v($tbl, 0, $this->inserts) + max(0, mysql_affected_rows($con)); + $dur = round($t2 - $t1, 4); + $this->insert_times[$tbl] = isset($this->insert_times[$tbl]) ? $this->insert_times[$tbl] : array('min' => $dur, 'max' => $dur, 'sum' => $dur); + $this->insert_times[$tbl] = array('min' => min($dur, $this->insert_times[$tbl]['min']), 'max' => max($dur, $this->insert_times[$tbl]['max']), 'sum' => $dur + $this->insert_times[$tbl]['sum']); + } + /* reset term id buffers */ + if ($reset_id_buffers) { + $this->term_ids = array(); + $this->triple_ids = array(); + } + /* refresh lock */ + if ($refresh_lock) { + $this->store->releaseLock(); + $this->has_lock = 0; + sleep(1); + if (!$this->store->getLock(5)) return $this->addError('Could not re-obtain lock in "checkSQLBuffers"'); + $this->has_lock = 1; + } + } + } + return 1; + } + + function autoRepairTable($er, $con, $sql = '') { + $this->addError('MySQL error: ' . $er . ' (' . $sql . ')'); + if (preg_match('/Table \'[^\']+\/([a-z0-9\_\-]+)\' .*(crashed|repair)/i', $er, $m)) { + $rs = $this->queryDB('REPAIR TABLE ' . rawurlencode($m[1]), $con); + $msg = $rs ? mysql_fetch_array($rs) : array(); + if ($this->v('Msg_type', 'error', $msg) == 'error') { + /* auto-reset */ + if ($this->v('store_reset_on_table_crash', 0, $this->a)) { + $this->store->drop(); + $this->store->setUp(); + } + else { + $er = $this->v('Msg_text', 'unknown error', $msg); + $this->addError('Auto-repair failed on ' . rawurlencode($m[1]) . ': ' . $er); + } + //die("Fatal errors: \n" . print_r($this->getErrors(), 1)); + } + } + } + + /* speed log */ + + function logInserts() { + $t_start = $this->t_start; + $t_prev = $this->t_prev; + $t_now = ARC2::mtime(); + $tc_prev = $this->t_count_prev; + $tc_now = $this->t_count; + $tc_diff = $tc_now - $tc_prev; + + $dur_full = $t_now - $t_start; + $dur_diff = $t_now - $t_prev; + + $speed_full = round($tc_now / $dur_full); + $speed_now = round($tc_diff / $dur_diff); + + $r = $tc_diff . ' in ' . round($dur_diff, 5) . ' = ' . $speed_now . ' t/s (' .$tc_now. ' in ' . round($dur_full, 5). ' = ' . $speed_full . ' t/s )'; + $fp = @fopen("arc_insert_log.txt", "a"); + @fwrite($fp, $r . "\r\n"); + @fclose($fp); + + $this->t_prev = $t_now; + $this->t_count_prev = $tc_now; + } + +} diff --git a/arc2-2.2.4/store/ARC2_StoreQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreQueryHandler.php new file mode 100755 index 0000000..282be77 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreQueryHandler.php @@ -0,0 +1,94 @@ + + * @homepage + * @package ARC2 + * @version 2010-11-16 +*/ + +ARC2::inc('Class'); + +class ARC2_StoreQueryHandler extends ARC2_Class { + + function __construct($a, &$caller) { + parent::__construct($a, $caller); + } + + function __init() {/* db_con */ + parent::__init(); + $this->xsd = 'http://www.w3.org/2001/XMLSchema#'; + $this->allow_extension_functions = $this->v('store_allow_extension_functions', 1, $this->a); + $this->keep_time_limit = $this->v('keep_time_limit', 0, $this->a); + $this->handler_type = ''; + } + + /* */ + + function getTermID($val, $term = '') { + return $this->store->getTermID($val, $term); + } + + function hasHashColumn($tbl) { + return $this->store->hasHashColumn($tbl); + } + + function getValueHash($val) { + return $this->store->getValueHash($val); + } + + /* */ + + function getTripleTable() { + $r = $this->store->getTablePrefix() . 'triple'; + return $r; + } + + /* */ + + function createMergeTable() { + $split_ps = $this->store->getSetting('split_predicates', array()); + if (!$split_ps) return 1; + $this->mrg_table_id = 'MRG_' . $this->store->getTablePrefix() . crc32(uniqid(rand())); + $con = $this->store->getDBCon(); + $this->queryDB("FLUSH TABLES", $con); + $indexes = $this->v('store_indexes', array('sp (s,p)', 'os (o,s)', 'po (p,o)'), $this->a); + $index_code = $indexes ? 'KEY ' . join(', KEY ', $indexes) . ', ' : ''; + $prefix = $this->store->getTablePrefix(); + $sql = " + CREATE TEMPORARY TABLE IF NOT EXISTS " . $prefix . "triple_all ( + t mediumint UNSIGNED NOT NULL, + s mediumint UNSIGNED NOT NULL, + p mediumint UNSIGNED NOT NULL, + o mediumint UNSIGNED NOT NULL, + o_lang_dt mediumint UNSIGNED NOT NULL, + o_comp char(35) NOT NULL, /* normalized value for ORDER BY operations */ + s_type tinyint(1) NOT NULL default 0, /* uri/bnode => 0/1 */ + o_type tinyint(1) NOT NULL default 0, /* uri/bnode/literal => 0/1/2 */ + misc tinyint(1) NOT NULL default 0, /* temporary flags */ + UNIQUE KEY (t), " . $index_code . " KEY (misc) + ) + "; + $v = $this->store->getDBVersion(); + $sql .= (($v < '04-01-00') && ($v >= '04-00-18')) ? 'ENGINE' : (($v >= '04-01-02') ? 'ENGINE' : 'TYPE'); + $sql .= "=MERGE UNION=(" . $prefix . "triple" ; + foreach ($split_ps as $pos => $p) { + $sql .= ',' . $prefix . 'triple_' . abs(crc32($p)); + } + $sql .= ")"; + //$sql .= ($v >= '04-00-00') ? " CHARACTER SET utf8" : ""; + //$sql .= ($v >= '04-01-00') ? " COLLATE utf8_unicode_ci" : ""; + //echo $sql; + return $this->queryDB($sql, $con); + } + + function dropMergeTable() { + return 1; + $sql = "DROP TABLE IF EXISTS " . $this->store->getTablePrefix() . "triple_all"; + //echo $sql; + return $this->queryDB($sql, $this->store->getDBCon()); + } + +} diff --git a/arc2-2.2.4/store/ARC2_StoreRDFXMLLoader.php b/arc2-2.2.4/store/ARC2_StoreRDFXMLLoader.php new file mode 100755 index 0000000..1a7b509 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreRDFXMLLoader.php @@ -0,0 +1,32 @@ +caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreRSSLoader.php b/arc2-2.2.4/store/ARC2_StoreRSSLoader.php new file mode 100755 index 0000000..7deb6eb --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreRSSLoader.php @@ -0,0 +1,32 @@ +caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreSGAJSONLoader.php b/arc2-2.2.4/store/ARC2_StoreSGAJSONLoader.php new file mode 100755 index 0000000..c95c8a2 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreSGAJSONLoader.php @@ -0,0 +1,36 @@ +extractRDF(); + } + + function addT($s, $p, $o, $s_type, $o_type, $o_dt = '', $o_lang = '') { + $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreSPOGLoader.php b/arc2-2.2.4/store/ARC2_StoreSPOGLoader.php new file mode 100755 index 0000000..1d1886e --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreSPOGLoader.php @@ -0,0 +1,38 @@ +caller->target_graph; + if ($this->caller->fixed_target_graph) $g = $this->caller->fixed_target_graph; + $prev_g = $this->caller->target_graph; + $this->caller->target_graph = $g; + $this->caller->addT($s, $p, $o, $s_type, $o_type, $o_dt, $o_lang); + $this->caller->target_graph = $prev_g; + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreSelectQueryHandler.php b/arc2-2.2.4/store/ARC2_StoreSelectQueryHandler.php new file mode 100755 index 0000000..3e1fafe --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreSelectQueryHandler.php @@ -0,0 +1,1799 @@ + + * @package ARC2 + * @version 2010-11-16 + * +*/ + +ARC2::inc('StoreQueryHandler'); + +class ARC2_StoreSelectQueryHandler extends ARC2_StoreQueryHandler { + + function __construct($a, &$caller) {/* caller has to be a store */ + parent::__construct($a, $caller); + } + + function __init() {/* db_con */ + parent::__init(); + $this->store = $this->caller; + $con = $this->store->getDBCon(); + $this->handler_type = 'select'; + $this->engine_type = $this->v('store_engine_type', 'MyISAM', $this->a); + $this->cache_results = $this->v('store_cache_results', 0, $this->a); + } + + /* */ + + function runQuery($infos) { + $con = $this->store->getDBCon(); + $rf = $this->v('result_format', '', $infos); + $this->infos = $infos; + $this->infos['null_vars'] = array(); + $this->indexes = array(); + $this->pattern_order_offset = 0; + $q_sql = $this->getSQL(); + + /* debug result formats */ + if ($rf == 'sql') return $q_sql; + if ($rf == 'structure') return $this->infos; + if ($rf == 'index') return $this->indexes; + /* create intermediate results (ID-based) */ + $tmp_tbl = $this->createTempTable($q_sql); + /* join values */ + $r = $this->getFinalQueryResult($q_sql, $tmp_tbl); + /* remove intermediate results */ + if (!$this->cache_results) { + $this->queryDB('DROP TABLE IF EXISTS ' . $tmp_tbl, $con); + } + return $r; + } + + function getSQL() { + $r = ''; + $nl = "\n"; + $this->buildInitialIndexes(); + foreach ($this->indexes as $i => $index) { + $this->index = array_merge($this->getEmptyIndex(), $index); + $this->analyzeIndex($this->getPattern('0')); + $sub_r = $this->getQuerySQL(); + $r .= $r ? $nl . 'UNION' . $this->getDistinctSQL() . $nl : ''; + $r .= $this->is_union_query ? '(' . $sub_r . ')' : $sub_r; + $this->indexes[$i] = $this->index; + } + $r .= $this->is_union_query ? $this->getLIMITSQL() : ''; + if ($this->v('order_infos', 0, $this->infos['query'])) { + $r = preg_replace('/SELECT(\s+DISTINCT)?\s*/', 'SELECT\\1 NULL AS `_pos_`, ', $r); + } + $pd_count = $this->problematicDependencies(); + if ($pd_count) { + /* re-arranging the patterns sometimes reduces the LEFT JOIN dependencies */ + $set_sql = 0; + if (!$this->pattern_order_offset) $set_sql = 1; + if (!$set_sql && ($pd_count < $this->opt_sql_pd_count)) $set_sql = 1; + if (!$set_sql && ($pd_count == $this->opt_sql_pd_count) && (strlen($r) < strlen($this->opt_sql))) $set_sql = 1; + if ($set_sql) { + $this->opt_sql = $r; + $this->opt_sql_pd_count = $pd_count; + } + $this->pattern_order_offset++; + if ($this->pattern_order_offset > 5) { + return $this->opt_sql; + } + return $this->getSQL(); + } + return $r; + } + + function buildInitialIndexes() { + $this->dependency_log = array(); + $this->index = $this->getEmptyIndex(); + $this->buildIndex($this->infos['query']['pattern'], 0); + $tmp = $this->index; + $this->analyzeIndex($this->getPattern('0')); + $this->initial_index = $this->index; + $this->index = $tmp; + $this->is_union_query = $this->index['union_branches'] ? 1 : 0; + $this->indexes = $this->is_union_query ? $this->getUnionIndexes($this->index) : array($this->index); + } + + function createTempTable($q_sql) { + $con = $this->store->getDBCon(); + $v = $this->store->getDBVersion(); + if ($this->cache_results) { + $tbl = $this->store->getTablePrefix() . 'Q' . md5($q_sql); + } + else { + $tbl = $this->store->getTablePrefix() . 'Q' . md5($q_sql . time() . uniqid(rand())); + } + if (strlen($tbl) > 64) $tbl = 'Q' . md5($tbl); + $tmp_sql = 'CREATE TEMPORARY TABLE ' . $tbl . ' ( ' . $this->getTempTableDef($tbl, $q_sql) . ') '; + $tmp_sql .= (($v < '04-01-00') && ($v >= '04-00-18')) ? 'ENGINE' : (($v >= '04-01-02') ? 'ENGINE' : 'TYPE'); + $tmp_sql .= '=' . $this->engine_type;/* HEAP doesn't support AUTO_INCREMENT, and MySQL breaks on MEMORY sometimes */ + if (!$this->queryDB($tmp_sql, $con) && !$this->queryDB(str_replace('CREATE TEMPORARY', 'CREATE', $tmp_sql), $con)) { + return $this->addError(mysql_error($con)); + } + mysql_unbuffered_query('INSERT INTO ' . $tbl . ' ' . "\n" . $q_sql, $con); + if ($er = mysql_error($con)) $this->addError($er); + return $tbl; + } + + function getEmptyIndex() { + return array( + 'from' => array(), + 'join' => array(), + 'left_join' => array(), + 'vars' => array(), 'graph_vars' => array(), 'graph_uris' => array(), + 'bnodes' => array(), + 'triple_patterns' => array(), + 'sub_joins' => array(), + 'constraints' => array(), + 'union_branches'=> array(), + 'patterns' => array(), + 'havings' => array() + ); + } + + function getTempTableDef($tmp_tbl, $q_sql) { + $col_part = preg_replace('/^SELECT\s*(DISTINCT)?(.*)FROM.*$/s', '\\2', $q_sql); + $parts = explode(',', $col_part); + $has_order_infos = $this->v('order_infos', 0, $this->infos['query']); + $r = ''; + $added = array(); + foreach ($parts as $part) { + if (preg_match('/\.?(.+)\s+AS\s+`(.+)`/U', trim($part), $m) && !isset($added[$m[2]])) { + $col = $m[1]; + $alias = $m[2]; + if ($alias == '_pos_') continue; + $r .= $r ? ',' : ''; + $r .= "\n `" . $alias . "` int UNSIGNED"; + $added[$alias] = 1; + } + } + if ($has_order_infos) { + $r = "\n" . '`_pos_` mediumint NOT NULL AUTO_INCREMENT PRIMARY KEY, ' . $r; + } + return $r ? $r . "\n" : ''; + } + + function getFinalQueryResult($q_sql, $tmp_tbl) { + /* var names */ + $vars = array(); + $aggregate_vars = array(); + foreach ($this->infos['query']['result_vars'] as $entry) { + if ($entry['aggregate']) { + $vars[] = $entry['alias']; + $aggregate_vars[] = $entry['alias']; + } + else { + $vars[] = $entry['var']; + } + } + /* result */ + $r = array('variables' => $vars); + $v_sql = $this->getValueSQL($tmp_tbl, $q_sql); + //echo "\n\n" . $v_sql; + $t1 = ARC2::mtime(); + $con = $this->store->getDBCon(); + $rs = mysql_unbuffered_query($v_sql, $con); + if ($er = mysql_error($con)) { + $this->addError($er); + } + $t2 = ARC2::mtime(); + $rows = array(); + $types = array(0 => 'uri', 1 => 'bnode', 2 => 'literal'); + if ($rs) { + while ($pre_row = mysql_fetch_array($rs)) { + $row = array(); + foreach ($vars as $var) { + if (isset($pre_row[$var])) { + $row[$var] = $pre_row[$var]; + $row[$var . ' type'] = isset($pre_row[$var . ' type']) ? $types[$pre_row[$var . ' type']] : (in_array($var, $aggregate_vars) ? 'literal' : 'uri'); + if (isset($pre_row[$var . ' lang_dt']) && ($lang_dt = $pre_row[$var . ' lang_dt'])) { + if (preg_match('/^([a-z]+(\-[a-z0-9]+)*)$/i', $lang_dt)) { + $row[$var . ' lang'] = $lang_dt; + } + else { + $row[$var . ' datatype'] = $lang_dt; + } + } + } + } + if ($row || !$vars) { + $rows[] = $row; + } + } + } + $r['rows'] = $rows; + return $r; + } + + /* */ + + function buildIndex($pattern, $id) { + $pattern['id'] = $id; + $type = $this->v('type', '', $pattern); + if (($type == 'filter') && $this->v('constraint', 0, $pattern)) { + $sub_pattern = $pattern['constraint']; + $sub_pattern['parent_id'] = $id; + $sub_id = $id . '_0'; + $this->buildIndex($sub_pattern, $sub_id); + $pattern['constraint'] = $sub_id; + } + else { + $sub_patterns = $this->v('patterns', array(), $pattern); + $keys = array_keys($sub_patterns); + $spc = count($sub_patterns); + if (($spc > 4) && $this->pattern_order_offset) { + $keys = array(); + for ($i = 0 ; $i < $spc; $i++) { + $keys[$i] = $i + $this->pattern_order_offset; + while ($keys[$i] >= $spc) $keys[$i] -= $spc; + } + } + foreach ($keys as $i => $key) { + $sub_pattern = $sub_patterns[$key]; + $sub_pattern['parent_id'] = $id; + $sub_id = $id . '_' . $key; + $this->buildIndex($sub_pattern, $sub_id); + $pattern['patterns'][$i] = $sub_id; + if ($type == 'union') { + $this->index['union_branches'][] = $sub_id; + } + } + } + $this->index['patterns'][$id] = $pattern; + } + + /* */ + + function analyzeIndex($pattern) { + $type = $this->v('type', '', $pattern); + if (!$type) { + //echo ''; + return false; + } + $type = $pattern['type']; + $id = $pattern['id']; + /* triple */ + if ($type == 'triple') { + foreach (array('s', 'p', 'o') as $term) { + if ($pattern[$term . '_type'] == 'var') { + $val = $pattern[$term]; + $this->index['vars'][$val] = array_merge($this->v($val, array(), $this->index['vars']), array(array('table' => $pattern['id'], 'col' =>$term))); + } + if ($pattern[$term . '_type'] == 'bnode') { + $val = $pattern[$term]; + $this->index['bnodes'][$val] = array_merge($this->v($val, array(), $this->index['bnodes']), array(array('table' => $pattern['id'], 'col' =>$term))); + } + } + $this->index['triple_patterns'][] = $pattern['id']; + /* joins */ + if ($this->isOptionalPattern($id)) { + $this->index['left_join'][] = $id; + } + elseif (!$this->index['from']) { + $this->index['from'][] = $id; + } + elseif (!$this->getJoinInfos($id)) { + $this->index['from'][] = $id; + } + else { + $this->index['join'][] = $id; + } + /* graph infos, graph vars */ + $this->index['patterns'][$id]['graph_infos'] = $this->getGraphInfos($id); + foreach ($this->index['patterns'][$id]['graph_infos'] as $info) { + if ($info['type'] == 'graph') { + if ($info['var']) { + $val = $info['var']['value']; + $this->index['graph_vars'][$val] = array_merge($this->v($val, array(), $this->index['graph_vars']), array(array('table' => $id))); + } + elseif ($info['uri']) { + $val = $info['uri']; + $this->index['graph_uris'][$val] = array_merge($this->v($val, array(), $this->index['graph_uris']), array(array('table' => $id))); + } + } + } + } + $sub_ids = $this->v('patterns', array(), $pattern); + foreach ($sub_ids as $sub_id) { + $this->analyzeIndex($this->getPattern($sub_id)); + } + } + + /* */ + + function getGraphInfos($id) { + $r = array(); + if ($id) { + $pattern = $this->index['patterns'][$id]; + $type = $pattern['type']; + /* graph */ + if ($type == 'graph') { + $r[] = array('type' => 'graph', 'var' => $pattern['var'], 'uri' => $pattern['uri']); + } + $p_pattern = $this->index['patterns'][$pattern['parent_id']]; + if (isset($p_pattern['graph_infos'])) { + return array_merge($p_pattern['graph_infos'], $r); + } + return array_merge($this->getGraphInfos($pattern['parent_id']), $r); + } + /* FROM / FROM NAMED */ + else { + if (isset($this->infos['query']['dataset'])) { + foreach ($this->infos['query']['dataset'] as $set) { + $r[] = array_merge(array('type' => 'dataset'), $set); + } + } + } + return $r; + } + + /* */ + + function getPattern($id) { + if (is_array($id)) { + return $id; + } + return $this->v($id, array(), $this->index['patterns']); + } + + function getInitialPattern($id) { + return $this->v($id, array(), $this->initial_index['patterns']); + } + + /* */ + + function getUnionIndexes($pre_index) { + $r = array(); + $branches = array(); + $min_depth = 1000; + /* only process branches with minimum depth */ + foreach ($pre_index['union_branches'] as $id) { + $branches[$id] = count(preg_split('/\_/', $id)); + $min_depth = min($min_depth, $branches[$id]); + } + foreach ($branches as $branch_id => $depth) { + if ($depth == $min_depth) { + $union_id = preg_replace('/\_[0-9]+$/', '', $branch_id); + $index = array('keeping' => $branch_id, 'union_branches' => array(), 'patterns' => $pre_index['patterns']); + $old_branches = $index['patterns'][$union_id]['patterns']; + $skip_id = ($old_branches[0] == $branch_id) ? $old_branches[1] : $old_branches[0]; + $index['patterns'][$union_id]['type'] = 'group'; + $index['patterns'][$union_id]['patterns'] = array($branch_id); + $has_sub_unions = 0; + foreach ($index['patterns'] as $pattern_id => $pattern) { + if (preg_match('/^' .$skip_id. '/', $pattern_id)) { + unset($index['patterns'][$pattern_id]); + } + elseif ($pattern['type'] == 'union') { + foreach ($pattern['patterns'] as $sub_union_branch_id) { + $index['union_branches'][] = $sub_union_branch_id; + } + } + } + if ($index['union_branches']) { + $r = array_merge($r, $this->getUnionIndexes($index)); + } + else { + $r[] = $index; + } + } + } + return $r; + } + + /* */ + + function isOptionalPattern($id) { + $pattern = $this->getPattern($id); + if ($this->v('type', '', $pattern) == 'optional') { + return 1; + } + if ($this->v('parent_id', '0', $pattern) == '0') { + return 0; + } + return $this->isOptionalPattern($pattern['parent_id']); + } + + function getOptionalPattern($id) { + $pn = $this->getPattern($id); + do { + $pn = $this->getPattern($pn['parent_id']); + } while ($pn['parent_id'] && ($pn['type'] != 'optional')); + return $pn['id']; + } + + function sameOptional($id, $id2) { + return $this->getOptionalPattern($id) == $this->getOptionalPattern($id2); + } + + /* */ + + function isUnionPattern($id) { + $pattern = $this->getPattern($id); + if ($this->v('type', '', $pattern) == 'union') { + return 1; + } + if ($this->v('parent_id', '0', $pattern) == '0') { + return 0; + } + return $this->isUnionPattern($pattern['parent_id']); + } + + /* */ + + function getValueTable($col) { + return $this->store->getTablePrefix() . (preg_match('/^(s|o)$/', $col) ? $col . '2val' : 'id2val'); + } + + function getGraphTable() { + return $this->store->getTablePrefix() . 'g2t'; + } + + /* */ + + function getQuerySQL() { + $nl = "\n"; + $where_sql = $this->getWHERESQL(); /* pre-fills $index['sub_joins'] $index['constraints'] */ + $order_sql = $this->getORDERSQL(); /* pre-fills $index['sub_joins'] $index['constraints'] */ + return '' . + ($this->is_union_query ? 'SELECT' : 'SELECT' . $this->getDistinctSQL()) . $nl . + $this->getResultVarsSQL() . $nl . /* fills $index['sub_joins'] */ + $this->getFROMSQL() . + $this->getAllJoinsSQL() . + $this->getWHERESQL() . + $this->getGROUPSQL() . + $this->getORDERSQL() . + ($this->is_union_query ? '' : $this->getLIMITSQL()) . + $nl . + ''; + } + + /* */ + + function getDistinctSQL() { + if ($this->is_union_query) { + return ($this->v('distinct', 0, $this->infos['query']) || $this->v('reduced', 0, $this->infos['query'])) ? '' : ' ALL'; + } + return ($this->v('distinct', 0, $this->infos['query']) || $this->v('reduced', 0, $this->infos['query'])) ? ' DISTINCT' : ''; + } + + /* */ + + function getResultVarsSQL() { + $r = ''; + $vars = $this->infos['query']['result_vars']; + $nl = "\n"; + $added = array(); + foreach ($vars as $var) { + $var_name = $var['var']; + $tbl_alias = ''; + if ($tbl_infos = $this->getVarTableInfos($var_name, 0)) { + $tbl = $tbl_infos['table']; + $col = $tbl_infos['col']; + $tbl_alias = $tbl_infos['table_alias']; + } + elseif ($var_name == 1) {/* ASK query */ + $r .= '1 AS `success`'; + } + else { + $this->addError('Result variable "' .$var_name. '" not used in query.'); + } + if ($tbl_alias) { + /* aggregate */ + if ($var['aggregate']) { + $conv_code = ''; + if (strtolower($var['aggregate']) != 'count') { + $tbl_alias = 'V_' . $tbl . '_' . $col . '.val'; + $conv_code = '0 + '; + } + if (!isset($added[$var['alias']])) { + $r .= $r ? ',' . $nl . ' ' : ' '; + $distinct_code = (strtolower($var['aggregate']) == 'count') && $this->v('distinct', 0, $this->infos['query']) ? 'DISTINCT ' : ''; + $r .= $var['aggregate'] . '(' . $conv_code . $distinct_code . $tbl_alias. ') AS `' . $var['alias'] . '`'; + $added[$var['alias']] = 1; + } + } + /* normal var */ + else { + if (!isset($added[$var_name])) { + $r .= $r ? ',' . $nl . ' ' : ' '; + $r .= $tbl_alias . ' AS `' . $var_name . '`'; + $is_s = ($col == 's'); + $is_p = ($col == 'p'); + $is_o = ($col == 'o'); + if ($tbl_alias == 'NULL') { + /* type / add in UNION queries? */ + if ($is_s || $is_o) { + $r .= ', ' . $nl . ' NULL AS `' . $var_name . ' type`'; + } + /* lang_dt / always add it in UNION queries, the var may be used as s/p/o */ + if ($is_o || $this->is_union_query) { + $r .= ', ' . $nl . ' NULL AS `' . $var_name . ' lang_dt`'; + } + } + else { + /* type */ + if ($is_s || $is_o) { + $r .= ', ' . $nl . ' ' .$tbl_alias . '_type AS `' . $var_name . ' type`'; + } + /* lang_dt / always add it in UNION queries, the var may be used as s/p/o */ + if ($is_o) { + $r .= ', ' . $nl . ' ' .$tbl_alias . '_lang_dt AS `' . $var_name . ' lang_dt`'; + } + elseif ($this->is_union_query) { + $r .= ', ' . $nl . ' NULL AS `' . $var_name . ' lang_dt`'; + } + } + $added[$var_name] = 1; + } + } + if (!in_array($tbl_alias, $this->index['sub_joins'])) { + $this->index['sub_joins'][] = $tbl_alias; + } + } + } + return $r ? $r : '1 AS `success`'; + } + + function getVarTableInfos($var, $ignore_initial_index = 1) { + if ($var == '*') { + return array('table' => '', 'col' => '', 'table_alias' => '*'); + } + if ($infos = $this->v($var, 0, $this->index['vars'])) { + $infos[0]['table_alias'] = 'T_' . $infos[0]['table'] . '.' . $infos[0]['col']; + return $infos[0]; + } + if ($infos = $this->v($var, 0, $this->index['graph_vars'])) { + $infos[0]['col'] = 'g'; + $infos[0]['table_alias'] = 'G_' . $infos[0]['table'] . '.' . $infos[0]['col']; + return $infos[0]; + } + if ($this->is_union_query && !$ignore_initial_index) { + if (($infos = $this->v($var, 0, $this->initial_index['vars'])) || ($infos = $this->v($var, 0, $this->initial_index['graph_vars']))) { + if (!in_array($var, $this->infos['null_vars'])) { + $this->infos['null_vars'][] = $var; + } + $infos[0]['table_alias'] = 'NULL'; + $infos[0]['col'] = !isset($infos[0]['col']) ? '' : $infos[0]['col']; + return $infos[0]; + } + } + return 0; + } + + /* */ + + function getFROMSQL() { + $from_ids = $this->index['from']; + $r = ''; + foreach ($from_ids as $from_id) { + $r .= $r ? ', ' : ''; + $r .= $this->getTripleTable($from_id) . ' T_' . $from_id; + } + /* MySQL 5 requires parentheses in case of multiple tables */ + /* MySQL >5.5 (?) does not allow parentheses in case of a single table anymore! */ + $r = (count($from_ids) > 1) ? '(' . $r . ')' : $r; + return $r ? 'FROM ' . $r : ''; + } + + /* */ + + function getOrderedJoinIDs() { + return array_merge($this->index['from'], $this->index['join'], $this->index['left_join']); + } + + function getJoinInfos($id) { + $r = array(); + $tbl_ids = $this->getOrderedJoinIDs(); + $pattern = $this->getPattern($id); + foreach ($tbl_ids as $tbl_id) { + $tbl_pattern = $this->getPattern($tbl_id); + if ($tbl_id != $id) { + foreach (array('s', 'p', 'o') as $tbl_term) { + foreach (array('var', 'bnode', 'uri') as $term_type) { + if ($tbl_pattern[$tbl_term . '_type'] == $term_type) { + foreach (array('s', 'p', 'o') as $term) { + if (($pattern[$term . '_type'] == $term_type) && ($tbl_pattern[$tbl_term] == $pattern[$term])) { + $r[] = array('term' => $term, 'join_tbl' => $tbl_id, 'join_term' => $tbl_term); + } + } + } + } + } + } + } + return $r; + } + + function getAllJoinsSQL() { + $js = $this->getJoins(); + $ljs = $this->getLeftJoins(); + $entries = array_merge($js, $ljs); + $id2code = array(); + foreach ($entries as $entry) { + if (preg_match('/([^\s]+) ON (.*)/s', $entry, $m)) { + $id2code[$m[1]] = $entry; + } + } + $deps = array(); + foreach ($id2code as $id => $code) { + $deps[$id]['rank'] = 0; + foreach ($id2code as $other_id => $other_code) { + $deps[$id]['rank'] += ($id != $other_id) && preg_match('/' . $other_id . '/', $code) ? 1 : 0; + $deps[$id][$other_id] = ($id != $other_id) && preg_match('/' . $other_id . '/', $code) ? 1 : 0; + } + } + $r = ''; + do { + /* get next 0-rank */ + $next_id = 0; + foreach ($deps as $id => $infos) { + if ($infos['rank'] == 0) { + $next_id = $id; + break; + } + } + if ($next_id) { + $r .= "\n" . $id2code[$next_id]; + unset($deps[$next_id]); + foreach ($deps as $id => $infos) { + $deps[$id]['rank'] = 0; + unset($deps[$id][$next_id]); + foreach ($infos as $k => $v) { + if (!in_array($k, array('rank', $next_id))) { + $deps[$id]['rank'] += $v; + $deps[$id][$k] = $v; + } + } + } + } + } + while ($next_id); + if ($deps) { + $this->addError('Not all patterns could be rewritten to SQL JOINs'); + } + return $r; + } + + function getJoins() { + $r = array(); + $nl = "\n"; + foreach ($this->index['join'] as $id) { + $sub_r = $this->getJoinConditionSQL($id); + $r[] = 'JOIN ' . $this->getTripleTable($id) . ' T_' . $id . ' ON (' . $sub_r . $nl . ')'; + } + foreach (array_merge($this->index['from'], $this->index['join']) as $id) { + if ($sub_r = $this->getRequiredSubJoinSQL($id)) { + $r[] = $sub_r; + } + } + return $r; + } + + function getLeftJoins() { + $r = array(); + $nl = "\n"; + foreach ($this->index['left_join'] as $id) { + $sub_r = $this->getJoinConditionSQL($id); + $r[] = 'LEFT JOIN ' . $this->getTripleTable($id) . ' T_' . $id . ' ON (' . $sub_r . $nl . ')'; + } + foreach ($this->index['left_join'] as $id) { + if ($sub_r = $this->getRequiredSubJoinSQL($id, 'LEFT')) { + $r[] = $sub_r; + } + } + return $r; + } + + function getJoinConditionSQL($id) { + $r = ''; + $nl = "\n"; + $infos = $this->getJoinInfos($id); + $pattern = $this->getPattern($id); + + $tbl = 'T_' . $id; + /* core dependency */ + $d_tbls = $this->getDependentJoins($id); + foreach ($d_tbls as $d_tbl) { + if (preg_match('/^T_([0-9\_]+)\.[spo]+/', $d_tbl, $m) && ($m[1] != $id)) { + if ($this->isJoinedBefore($m[1], $id) && !in_array($m[1], array_merge($this->index['from'], $this->index['join']))) { + $r .= $r ? $nl . ' AND ' : $nl . ' '; + $r .= '(' . $d_tbl . ' IS NOT NULL)'; + } + $this->logDependency($id, $d_tbl); + } + } + /* triple-based join info */ + foreach ($infos as $info) { + if ($this->isJoinedBefore($info['join_tbl'], $id) && $this->joinDependsOn($id, $info['join_tbl'])) { + $r .= $r ? $nl . ' AND ' : $nl . ' '; + $r .= '(' . $tbl . '.' . $info['term'] . ' = T_' . $info['join_tbl'] . '.' . $info['join_term'] . ')'; + } + } + /* filters etc */ + if ($sub_r = $this->getPatternSQL($pattern, 'join__T_' . $id)) { + $r .= $r ? $nl . ' AND ' . $sub_r : $nl . ' ' . '(' . $sub_r . ')'; + } + return $r; + } + + /** + * A log of identified table join dependencies in getJoinConditionSQL + * + */ + + function logDependency($id, $tbl) { + if (!isset($this->dependency_log[$id])) $this->dependency_log[$id] = array(); + if (!in_array($tbl, $this->dependency_log[$id])) { + $this->dependency_log[$id][] = $tbl; + } + } + + /** + * checks whether entries in the dependecy log could perhaps be optimized + * (triggers re-ordering of patterns + */ + + function problematicDependencies() { + foreach ($this->dependency_log as $id => $tbls) { + if (count($tbls) > 1) return count($tbls); + } + return 0; + } + + function isJoinedBefore($tbl_1, $tbl_2) { + $tbl_ids = $this->getOrderedJoinIDs(); + foreach ($tbl_ids as $id) { + if ($id == $tbl_1) { + return 1; + } + if ($id == $tbl_2) { + return 0; + } + } + } + + function joinDependsOn($id, $id2) { + if (in_array($id2, array_merge($this->index['from'], $this->index['join']))) { + return 1; + } + $d_tbls = $this->getDependentJoins($id2); + //echo $id . ' :: ' . $id2 . '=>' . print_r($d_tbls, 1); + foreach ($d_tbls as $d_tbl) { + if (preg_match('/^T_' .$id. '\./', $d_tbl)) { + return 1; + } + } + return 0; + } + + function getDependentJoins($id) { + $r = array(); + /* sub joins */ + foreach ($this->index['sub_joins'] as $alias) { + if (preg_match('/^(T|V|G)_' . $id . '/', $alias)) { + $r[] = $alias; + } + } + /* siblings in shared optional */ + $o_id = $this->getOptionalPattern($id); + foreach ($this->index['sub_joins'] as $alias) { + if (preg_match('/^(T|V|G)_' . $o_id . '/', $alias) && !in_array($alias, $r)) { + $r[] = $alias; + } + } + foreach ($this->index['left_join'] as $alias) { + if (preg_match('/^' . $o_id . '/', $alias) && !in_array($alias, $r)) { + $r[] = 'T_' . $alias . '.s'; + } + } + return $r; + } + + /* */ + + function getRequiredSubJoinSQL($id, $prefix = '') {/* id is a triple pattern id. Optional FILTERS and GRAPHs are getting added to the join directly */ + $nl = "\n"; + $r = ''; + foreach ($this->index['sub_joins'] as $alias) { + if (preg_match('/^V_' . $id . '_([a-z\_]+)\.val$/', $alias, $m)) { + $col = $m[1]; + $sub_r = ''; + if ($this->isOptionalPattern($id)) { + $pattern = $this->getPattern($id); + do { + $pattern = $this->getPattern($pattern['parent_id']); + } while ($pattern['parent_id'] && ($pattern['type'] != 'optional')); + $sub_r = $this->getPatternSQL($pattern, 'sub_join__V_' . $id); + } + $sub_r = $sub_r ? $nl . ' AND (' . $sub_r . ')' : ''; + /* lang dt only on literals */ + if ($col == 'o_lang_dt') { + $sub_sub_r = 'T_' . $id . '.o_type = 2'; + $sub_r .= $nl . ' AND (' . $sub_sub_r . ')'; + } + //$cur_prefix = $prefix ? $prefix . ' ' : 'STRAIGHT_'; + $cur_prefix = $prefix ? $prefix . ' ' : ''; + if ($col == 'g') { + $r .= trim($cur_prefix . 'JOIN '. $this->getValueTable($col) . ' V_' .$id . '_' . $col. ' ON (' .$nl. ' (G_' . $id . '.' . $col. ' = V_' . $id. '_' . $col. '.id) ' . $sub_r . $nl . ')'); + } + else { + $r .= trim($cur_prefix . 'JOIN '. $this->getValueTable($col) . ' V_' .$id . '_' . $col. ' ON (' .$nl. ' (T_' . $id . '.' . $col. ' = V_' . $id. '_' . $col. '.id) ' . $sub_r . $nl . ')'); + } + } + elseif (preg_match('/^G_' . $id . '\.g$/', $alias, $m)) { + $pattern = $this->getPattern($id); + $sub_r = $this->getPatternSQL($pattern, 'graph_sub_join__G_' . $id); + $sub_r = $sub_r ? $nl . ' AND ' . $sub_r : ''; + /* dataset restrictions */ + $gi = $this->getGraphInfos($id); + $sub_sub_r = ''; + $added_gts = array(); + foreach ($gi as $set) { + if (isset($set['graph']) && !in_array($set['graph'], $added_gts)) { + $sub_sub_r .= $sub_sub_r !== '' ? ',' : ''; + $sub_sub_r .= $this->getTermID($set['graph'], 'g'); + $added_gts[] = $set['graph']; + } + } + $sub_r .= ($sub_sub_r !== '') ? $nl . ' AND (G_' . $id . '.g IN (' . $sub_sub_r . '))' : ''; // /* ' . str_replace('#' , '::', $set['graph']) . ' */'; + /* other graph join conditions */ + foreach ($this->index['graph_vars'] as $var => $occurs) { + $occur_tbls = array(); + foreach ($occurs as $occur) { + $occur_tbls[] = $occur['table']; + if ($occur['table'] == $id) break; + } + foreach($occur_tbls as $tbl) { + if (($tbl != $id) && in_array($id, $occur_tbls) && $this->isJoinedBefore($tbl, $id)) { + $sub_r .= $nl . ' AND (G_' .$id. '.g = G_' .$tbl. '.g)'; + } + } + } + //$cur_prefix = $prefix ? $prefix . ' ' : 'STRAIGHT_'; + $cur_prefix = $prefix ? $prefix . ' ' : ''; + $r .= trim($cur_prefix . 'JOIN '. $this->getGraphTable() . ' G_' .$id . ' ON (' .$nl. ' (T_' . $id . '.t = G_' .$id. '.t)' . $sub_r . $nl . ')'); + } + } + return $r; + } + + /* */ + + function getWHERESQL() { + $r = ''; + $nl = "\n"; + /* standard constraints */ + $sub_r = $this->getPatternSQL($this->getPattern('0'), 'where'); + /* additional constraints */ + foreach ($this->index['from'] as $id) { + if ($sub_sub_r = $this->getConstraintSQL($id)) { + $sub_r .= $sub_r ? $nl . ' AND ' . $sub_sub_r : $sub_sub_r; + } + } + $r .= $sub_r ? $sub_r : ''; + /* left join dependencies */ + foreach ($this->index['left_join'] as $id) { + $d_joins = $this->getDependentJoins($id); + $added = array(); + $d_aliases = array(); + //echo $id . ' =>' . print_r($d_joins, 1); + $id_alias = 'T_' . $id . '.s'; + foreach ($d_joins as $alias) { + if (preg_match('/^(T|V|G)_([0-9\_]+)(_[spo])?\.([a-z\_]+)/', $alias, $m)) { + $tbl_type = $m[1]; + $tbl_pattern_id = $m[2]; + $suffix = $m[3]; + if (($tbl_pattern_id >= $id) && $this->sameOptional($tbl_pattern_id, $id)) {/* get rid of dependency permutations and nested optionals */ + if (!in_array($tbl_type . '_' . $tbl_pattern_id . $suffix, $added)) { + $sub_r .= $sub_r ? ' AND ' : ''; + $sub_r .= $alias . ' IS NULL'; + $d_aliases[] = $alias; + $added[] = $tbl_type . '_' . $tbl_pattern_id . $suffix; + $id_alias = ($tbl_pattern_id == $id) ? $alias : $id_alias; + } + } + } + } + if (count($d_aliases) > 2) {/* @@todo fix this! */ + $sub_r1 = ' /* '.$id_alias.' dependencies */'; + $sub_r2 = '((' . $id_alias . ' IS NULL) OR (CONCAT(' . join(', ', $d_aliases) . ') IS NOT NULL))'; + $r .= $r ? $nl . $sub_r1 . $nl . ' AND ' .$sub_r2 : $sub_r1 . $nl . $sub_r2; + } + } + return $r ? $nl . 'WHERE ' . $r : ''; + } + + /* */ + + function addConstraintSQLEntry($id, $sql) { + if (!isset($this->index['constraints'][$id])) { + $this->index['constraints'][$id] = array(); + } + if (!in_array($sql, $this->index['constraints'][$id])) { + $this->index['constraints'][$id][] = $sql; + } + } + + function getConstraintSQL($id) { + $r = ''; + $nl = "\n"; + $constraints = $this->v($id, array(), $this->index['constraints']); + foreach ($constraints as $constraint) { + $r .= $r ? $nl . ' AND ' . $constraint : $constraint; + } + return $r; + } + + /* */ + + function getPatternSQL($pattern, $context) { + $type = $this->v('type', '', $pattern); + if (!$type) { + return ''; + } + $m = 'get' . ucfirst($type) . 'PatternSQL'; + return method_exists($this, $m) ? $this->$m($pattern, $context) : $this->getDefaultPatternSQL($pattern, $context); + } + + function getDefaultPatternSQL($pattern, $context) { + $r = ''; + $nl = "\n"; + $sub_ids = $this->v('patterns', array(), $pattern); + foreach ($sub_ids as $sub_id) { + $sub_r = $this->getPatternSQL($this->getPattern($sub_id), $context); + $r .= ($r && $sub_r) ? $nl . ' AND (' . $sub_r . ')' : ($sub_r ? $sub_r : ''); + } + return $r ? $r : ''; + } + + function getTriplePatternSQL($pattern, $context) { + $r = ''; + $nl = "\n"; + $id = $pattern['id']; + /* s p o */ + $vars = array(); + foreach (array('s', 'p', 'o') as $term) { + $sub_r = ''; + $type = $pattern[$term . '_type']; + if ($type == 'uri') { + $term_id = $this->getTermID($pattern[$term], $term); + $sub_r = '(T_' . $id . '.' . $term . ' = ' . $term_id . ') /* ' . preg_replace('/[\#\*\>]/' , '::', $pattern[$term]) . ' */'; + } + elseif ($type == 'literal') { + $term_id = $this->getTermID($pattern[$term], $term); + $sub_r = '(T_' . $id . '.' . $term . ' = ' . $term_id . ') /* ' . preg_replace('/[\#\n\*\>]/' , ' ', $pattern[$term]) . ' */'; + if (($lang_dt = $this->v1($term . '_lang', '', $pattern)) || ($lang_dt = $this->v1($term . '_datatype', '', $pattern))) { + $lang_dt_id = $this->getTermID($lang_dt); + $sub_r .= $nl . ' AND (T_' . $id . '.' .$term. '_lang_dt = ' . $lang_dt_id . ') /* ' . preg_replace('/[\#\*\>]/' , '::', $lang_dt) . ' */'; + } + } + elseif ($type == 'var') { + $val = $pattern[$term]; + if (isset($vars[$val])) {/* repeated var in pattern */ + $sub_r = '(T_' . $id . '.' . $term . '=' . 'T_' . $id . '.' . $vars[$val] . ')'; + } + $vars[$val] = $term; + if ($infos = $this->v($val, 0, $this->index['graph_vars'])) {/* graph var in triple pattern */ + $sub_r .= $sub_r ? $nl . ' AND ' : ''; + $tbl = $infos[0]['table']; + $sub_r .= 'G_' . $tbl . '.g = T_' . $id . '.' . $term; + } + } + if ($sub_r) { + if (preg_match('/^(join)/', $context) || (preg_match('/^where/', $context) && in_array($id, $this->index['from']))) { + $r .= $r ? $nl . ' AND ' . $sub_r : $sub_r; + } + } + } + /* g */ + if ($infos = $pattern['graph_infos']) { + $tbl_alias = 'G_' . $id . '.g'; + if (!in_array($tbl_alias, $this->index['sub_joins'])) { + $this->index['sub_joins'][] = $tbl_alias; + } + $sub_r = array('graph_var' => '', 'graph_uri' => '', 'from' => '', 'from_named' => ''); + foreach ($infos as $info) { + $type = $info['type']; + if ($type == 'graph') { + if ($info['uri']) { + $term_id = $this->getTermID($info['uri'], 'g'); + $sub_r['graph_uri'] .= $sub_r['graph_uri'] ? $nl . ' AND ' : ''; + $sub_r['graph_uri'] .= '(' .$tbl_alias. ' = ' . $term_id . ') /* ' . preg_replace('/[\#\*\>]/' , '::', $info['uri']) . ' */'; + } + } + } + if ($sub_r['from'] && $sub_r['from_named']) { + $sub_r['from_named'] = ''; + } + if (!$sub_r['from'] && !$sub_r['from_named']) { + $sub_r['graph_var'] = ''; + } + if (preg_match('/^(graph_sub_join)/', $context)) { + foreach ($sub_r as $g_type => $g_sql) { + if ($g_sql) { + $r .= $r ? $nl . ' AND ' . $g_sql : $g_sql; + } + } + } + } + /* optional sibling filters? */ + if (preg_match('/^(join|sub_join)/', $context) && $this->isOptionalPattern($id)) { + $o_pattern = $pattern; + do { + $o_pattern = $this->getPattern($o_pattern['parent_id']); + } while ($o_pattern['parent_id'] && ($o_pattern['type'] != 'optional')); + if ($sub_r = $this->getPatternSQL($o_pattern, 'optional_filter' . preg_replace('/^(.*)(__.*)$/', '\\2', $context))) { + $r .= $r ? $nl . ' AND ' . $sub_r : $sub_r; + } + /* created constraints */ + if ($sub_r = $this->getConstraintSQL($id)) { + $r .= $r ? $nl . ' AND ' . $sub_r : $sub_r; + } + } + /* result */ + if (preg_match('/^(where)/', $context) && $this->isOptionalPattern($id)) { + return ''; + } + return $r; + } + + /* */ + + function getFilterPatternSQL($pattern, $context) { + $r = ''; + $id = $pattern['id']; + $constraint_id = $this->v1('constraint', '', $pattern); + $constraint = $this->getPattern($constraint_id); + $constraint_type = $constraint['type']; + if ($constraint_type == 'built_in_call') { + $r = $this->getBuiltInCallSQL($constraint, $context); + } + elseif ($constraint_type == 'expression') { + $r = $this->getExpressionSQL($constraint, $context, '', 'filter'); + } + else { + $m = 'get' . ucfirst($constraint_type) . 'ExpressionSQL'; + if (method_exists($this, $m)) { + $r = $this->$m($constraint, $context, '', 'filter'); + } + } + if ($this->isOptionalPattern($id) && !preg_match('/^(join|optional_filter)/', $context)) { + return ''; + } + /* unconnected vars in FILTERs eval to false */ + $sub_r = $this->hasUnconnectedFilterVars($id); + if ($sub_r) { + if ($sub_r == 'alias') { + if (!in_array($r, $this->index['havings'])) $this->index['havings'][] = $r; + return ''; + } + elseif (preg_match('/^T([^\s]+\.)g (.*)$/s', $r, $m)) {/* graph filter */ + return 'G' . $m[1] . 't ' . $m[2]; + } + elseif (preg_match('/^\(*V[^\s]+_g\.val .*$/s', $r, $m)) {/* graph value filter, @@improveMe */ + //return $r; + } + else { + return 'FALSE'; + } + } + /* some really ugly tweaks */ + /* empty language filter: FILTER ( lang(?v) = '' ) */ + $r = preg_replace('/\(\/\* language call \*\/ ([^\s]+) = ""\)/s', '((\\1 = "") OR (\\1 LIKE "%:%"))', $r); + return $r; + } + + /** + * Checks if vars in the given (filter) pattern are used within the filter's scope. + */ + + function hasUnconnectedFilterVars($filter_pattern_id) { + $scope_id = $this->getFilterScope($filter_pattern_id); + $vars = $this->getFilterVars($filter_pattern_id); + $r = 0; + foreach ($vars as $var_name) { + if ($this->isUsedTripleVar($var_name, $scope_id)) continue; + if ($this->isAliasVar($var_name)) { + $r = 'alias'; + break; + } + $r = 1; + break; + } + return $r; + } + + /** + * Returns the given filter pattern's scope (the id of the parent group pattern). + */ + + function getFilterScope($filter_pattern_id) { + $patterns = $this->initial_index['patterns']; + $r = ''; + foreach ($patterns as $id => $p) { + /* the id has to be sub-part of the given filter id */ + if (!preg_match('/^' . $id . '.+/', $filter_pattern_id)) continue; + /* we are looking for a group or union */ + if (!preg_match('/^(group|union)$/', $p['type'])) continue; + /* we are looking for the longest/deepest match */ + if (strlen($id) > strlen($r)) $r = $id; + } + return $r; + } + + /** + * Builds a list of vars used in the given (filter) pattern. + */ + + function getFilterVars($filter_pattern_id) { + $r = array(); + $patterns = $this->initial_index['patterns']; + /* find vars in the given filter (i.e. the given id is part of their pattern id) */ + foreach ($patterns as $id => $p) { + if (!preg_match('/^' . $filter_pattern_id . '.+/', $id)) continue; + $var_name = ''; + if ($p['type'] == 'var') { + $var_name = $p['value']; + } + elseif (($p['type'] == 'built_in_call') && ($p['call'] == 'bound')) { + $var_name = $p['args'][0]['value']; + } + if ($var_name && !in_array($var_name, $r)) { + $r[] = $var_name; + } + } + return $r; + } + + /** + * Checks if $var_name appears as result projection alias. + */ + + function isAliasVar($var_name) { + foreach ($this->infos['query']['result_vars'] as $r_var) { + if ($r_var['alias'] == $var_name) return 1; + } + return 0; + } + + /** + * Checks if $var_name is used in a triple pattern in the given scope + */ + + function isUsedTripleVar($var_name, $scope_id = '0') { + $patterns = $this->initial_index['patterns']; + foreach ($patterns as $id => $p) { + if ($p['type'] != 'triple') continue; + if (!preg_match('/^' . $scope_id . '.+/', $id)) continue; + foreach (array('s', 'p', 'o') as $term) { + if ($p[$term . '_type'] != 'var') continue; + if ($p[$term] == $var_name) return 1; + } + } + } + + /* */ + + function getExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $r = ''; + $nl = "\n"; + $type = $this->v1('type', '', $pattern); + $sub_type = $this->v1('sub_type', $type, $pattern); + if (preg_match('/^(and|or)$/', $sub_type)) { + foreach ($pattern['patterns'] as $sub_id) { + $sub_pattern = $this->getPattern($sub_id); + $sub_pattern_type = $sub_pattern['type']; + if ($sub_pattern_type == 'built_in_call') { + $sub_r = $this->getBuiltInCallSQL($sub_pattern, $context, '', $parent_type); + } + else { + $sub_r = $this->getExpressionSQL($sub_pattern, $context, '', $parent_type); + } + if ($sub_r) { + $r .= $r ? ' ' . strtoupper($sub_type). ' (' .$sub_r. ')' : '(' . $sub_r . ')'; + } + } + } + elseif ($sub_type == 'built_in_call') { + $r = $this->getBuiltInCallSQL($pattern, $context, $val_type, $parent_type); + } + elseif (preg_match('/literal/', $sub_type)) { + $r = $this->getLiteralExpressionSQL($pattern, $context, $val_type, $parent_type); + } + elseif ($sub_type) { + $m = 'get' . ucfirst($sub_type) . 'ExpressionSQL'; + if (method_exists($this, $m)) { + $r = $this->$m($pattern, $context, '', $parent_type); + } + } + /* skip expressions that reference non-yet-joined tables */ + if (preg_match('/__(T|V|G)_(.+)$/', $context, $m)) { + $context_pattern_id = $m[2]; + $context_table_type = $m[1]; + if (preg_match_all('/((T|V|G)(\_[0-9])+)/', $r, $m)) { + $aliases = $m[1]; + $keep = 1; + foreach ($aliases as $alias) { + if (preg_match('/(T|V|G)_(.*)$/', $alias, $m)) { + $tbl_type = $m[1]; + $tbl = $m[2]; + if (!$this->isJoinedBefore($tbl, $context_pattern_id)) { + $keep = 0; + } + elseif (($context_pattern_id == $tbl) && preg_match('/(TV)/', $context_table_type . $tbl_type)) { + $keep = 0; + } + } + } + $r = $keep ? $r : ''; + } + } + return $r ? '(' . $r . ')' : $r; + } + + function detectExpressionValueType($pattern_ids) { + foreach ($pattern_ids as $id) { + $pattern = $this->getPattern($id); + $type = $this->v('type', '', $pattern); + if (($type == 'literal') && isset($pattern['datatype'])) { + if (in_array($pattern['datatype'], array($this->xsd . 'integer', $this->xsd . 'float', $this->xsd . 'double'))) { + return 'numeric'; + } + } + } + return ''; + } + + /* */ + + function getRelationalExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $r = ''; + $val_type = $this->detectExpressionValueType($pattern['patterns']); + $op = $pattern['operator']; + foreach ($pattern['patterns'] as $sub_id) { + $sub_pattern = $this->getPattern($sub_id); + $sub_pattern['parent_op'] = $op; + $sub_type = $sub_pattern['type']; + $m = ($sub_type == 'built_in_call') ? 'getBuiltInCallSQL' : 'get' . ucfirst($sub_type) . 'ExpressionSQL'; + $m = str_replace('ExpressionExpression', 'Expression', $m); + $sub_r = method_exists($this, $m) ? $this->$m($sub_pattern, $context, $val_type, 'relational') : ''; + $r .= $r ? ' ' . $op . ' ' . $sub_r : $sub_r; + } + return $r ? '(' . $r . ')' : $r; + } + + function getAdditiveExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $r = ''; + $val_type = $this->detectExpressionValueType($pattern['patterns']); + foreach ($pattern['patterns'] as $sub_id) { + $sub_pattern = $this->getPattern($sub_id); + $sub_type = $this->v('type', '', $sub_pattern); + $m = ($sub_type == 'built_in_call') ? 'getBuiltInCallSQL' : 'get' . ucfirst($sub_type) . 'ExpressionSQL'; + $m = str_replace('ExpressionExpression', 'Expression', $m); + $sub_r = method_exists($this, $m) ? $this->$m($sub_pattern, $context, $val_type, 'additive') : ''; + $r .= $r ? ' ' . $sub_r : $sub_r; + } + return $r; + } + + function getMultiplicativeExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $r = ''; + $val_type = $this->detectExpressionValueType($pattern['patterns']); + foreach ($pattern['patterns'] as $sub_id) { + $sub_pattern = $this->getPattern($sub_id); + $sub_type = $sub_pattern['type']; + $m = ($sub_type == 'built_in_call') ? 'getBuiltInCallSQL' : 'get' . ucfirst($sub_type) . 'ExpressionSQL'; + $m = str_replace('ExpressionExpression', 'Expression', $m); + $sub_r = method_exists($this, $m) ? $this->$m($sub_pattern, $context, $val_type, 'multiplicative') : ''; + $r .= $r ? ' ' . $sub_r : $sub_r; + } + return $r; + } + + /* */ + + function getVarExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $var = $pattern['value']; + $info = $this->getVarTableInfos($var); + if (!$tbl = $info['table']) { + /* might be an aggregate var */ + $vars = $this->infos['query']['result_vars']; + foreach ($vars as $test_var) { + if ($test_var['alias'] == $pattern['value']) { + return '`' . $pattern['value'] . '`'; + } + } + return ''; + } + $col = $info['col']; + if (($context == 'order') && ($col == 'o')) { + $tbl_alias = 'T_' . $tbl . '.o_comp'; + } + elseif ($context == 'sameterm') { + $tbl_alias = 'T_' . $tbl . '.' . $col; + } + elseif (($parent_type == 'relational') && ($col == 'o') && (preg_match('/[\<\>]/', $this->v('parent_op', '', $pattern)))) { + $tbl_alias = 'T_' . $tbl . '.o_comp'; + } + else { + $tbl_alias = 'V_' . $tbl . '_' . $col . '.val'; + if (!in_array($tbl_alias, $this->index['sub_joins'])) { + $this->index['sub_joins'][] = $tbl_alias; + } + } + $op = $this->v('operator', '', $pattern); + if (preg_match('/^(filter|and)/', $parent_type)) { + if ($op == '!') { + $r = '(((' . $tbl_alias . ' = 0) AND (CONCAT("1", ' . $tbl_alias . ') != 1))'; /* 0 and no string */ + $r .= ' OR (' . $tbl_alias . ' IN ("", "false")))'; /* or "", or "false" */ + } + else { + $r = '((' . $tbl_alias . ' != 0)'; /* not null */ + $r .= ' OR ((CONCAT("1", ' . $tbl_alias . ') = 1) AND (' . $tbl_alias . ' NOT IN ("", "false"))))'; /* string, and not "" or "false" */ + } + } + else { + $r = trim($op . ' ' . $tbl_alias); + if ($val_type == 'numeric') { + if (preg_match('/__(T|V|G)_(.+)$/', $context, $m)) { + $context_pattern_id = $m[2]; + $context_table_type = $m[1]; + } + else { + $context_pattern_id = $pattern['id']; + $context_table_type = 'T'; + } + if ($this->isJoinedBefore($tbl, $context_pattern_id)) { + $add = ($tbl != $context_pattern_id) ? 1 : 0; + $add = (!$add && ($context_table_type == 'V')) ? 1 : 0; + if ($add) { + $this->addConstraintSQLEntry($context_pattern_id, '(' .$r. ' = "0" OR ' . $r . '*1.0 != 0)'); + } + } + } + } + return $r; + } + + /* */ + + function getUriExpressionSQL($pattern, $context, $val_type = '') { + $val = $pattern['uri']; + $r = $pattern['operator']; + $r .= is_numeric($val) ? ' ' . $val : ' "' . mysql_real_escape_string($val, $this->store->getDBCon()) . '"'; + return $r; + } + + /* */ + + function getLiteralExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $val = $pattern['value']; + $r = $pattern['operator']; + if (is_numeric($val) && $this->v('datatype', 0, $pattern)) { + $r .= ' ' . $val; + } + elseif (preg_match('/^(true|false)$/i', $val) && ($this->v1('datatype', '', $pattern) == 'http://www.w3.org/2001/XMLSchema#boolean')) { + $r .= ' ' . strtoupper($val); + } + elseif ($parent_type == 'regex') { + $sub_r = mysql_real_escape_string($val, $this->store->getDBCon()); + $r .= ' "' . preg_replace('/\x5c\x5c/', '\\', $sub_r) . '"'; + } + else { + $r .= ' "' . mysql_real_escape_string($val, $this->store->getDBCon()) . '"'; + } + if (($lang_dt = $this->v1('lang', '', $pattern)) || ($lang_dt = $this->v1('datatype', '', $pattern))) { + /* try table/alias via var in siblings */ + if ($var = $this->findSiblingVarExpression($pattern['id'])) { + if (isset($this->index['vars'][$var])) { + $infos = $this->index['vars'][$var]; + foreach ($infos as $info) { + if ($info['col'] == 'o') { + $tbl = $info['table']; + $term_id = $this->getTermID($lang_dt); + if ($pattern['operator'] != '!=') { + if (preg_match('/__(T|V|G)_(.+)$/', $context, $m)) { + $context_pattern_id = $m[2]; + $context_table_type = $m[1]; + } + elseif ($context == 'where') { + $context_pattern_id = $tbl; + } + else { + $context_pattern_id = $pattern['id']; + } + if ($tbl == $context_pattern_id) {/* @todo better dependency check */ + if ($term_id || ($lang_dt != 'http://www.w3.org/2001/XMLSchema#integer')) {/* skip if simple int, but no id */ + $this->addConstraintSQLEntry($context_pattern_id, 'T_' . $tbl . '.o_lang_dt = ' . $term_id . ' /* ' . preg_replace('/[\#\*\>]/' , '::', $lang_dt) . ' */'); + } + } + } + break; + } + } + } + } + } + return trim($r); + } + + function findSiblingVarExpression($id) { + $pattern = $this->getPattern($id); + do { + $pattern = $this->getPattern($pattern['parent_id']); + } while ($pattern['parent_id'] && ($pattern['type'] != 'expression')); + $sub_patterns = $this->v('patterns', array(), $pattern); + foreach ($sub_patterns as $sub_id) { + $sub_pattern = $this->getPattern($sub_id); + if ($sub_pattern['type'] == 'var') { + return $sub_pattern['value']; + } + } + return ''; + } + + /* */ + + function getFunctionExpressionSQL($pattern, $context, $val_type = '', $parent_type = '') { + $fnc_uri = $pattern['uri']; + $op = $this->v('operator', '', $pattern); + if ($op) $op .= ' '; + if ($this->allow_extension_functions) { + /* mysql functions */ + if (preg_match('/^http\:\/\/web\-semantics\.org\/ns\/mysql\/(.*)$/', $fnc_uri, $m)) { + $fnc_name = strtoupper($m[1]); + $sub_r = ''; + foreach ($pattern['args'] as $arg) { + $sub_r .= $sub_r ? ', ' : ''; + $sub_r .= $this->getExpressionSQL($arg, $context, $val_type, $parent_type); + } + return $op . $fnc_name . '(' . $sub_r . ')'; + } + /* any other: ignore */ + } + /* simple type conversions */ + if (strpos($fnc_uri, 'http://www.w3.org/2001/XMLSchema#') === 0) { + return $op . $this->getExpressionSQL($pattern['args'][0], $context, $val_type, $parent_type); + } + return ''; + } + + /* */ + + function getBuiltInCallSQL($pattern, $context) { + $call = $pattern['call']; + $m = 'get' . ucfirst($call) . 'CallSQL'; + if (method_exists($this, $m)) { + return $this->$m($pattern, $context); + } + else { + $this->addError('Unknown built-in call "' . $call . '"'); + } + return ''; + } + + function getBoundCallSQL($pattern, $context) { + $r = ''; + $var = $pattern['args'][0]['value']; + $info = $this->getVarTableInfos($var); + if (!$tbl = $info['table']) { + return ''; + } + $col = $info['col']; + $tbl_alias = 'T_' . $tbl . '.' . $col; + if ($pattern['operator'] == '!') { + return $tbl_alias . ' IS NULL'; + } + return $tbl_alias . ' IS NOT NULL'; + } + + function getHasTypeCallSQL($pattern, $context, $type) { + $r = ''; + $var = $pattern['args'][0]['value']; + $info = $this->getVarTableInfos($var); + if (!$tbl = $info['table']) { + return ''; + } + $col = $info['col']; + $tbl_alias = 'T_' . $tbl . '.' . $col . '_type'; + return $tbl_alias . ' ' .$this->v('operator', '', $pattern) . '= ' . $type; + } + + function getIsliteralCallSQL($pattern, $context) { + return $this->getHasTypeCallSQL($pattern, $context, 2); + } + + function getIsblankCallSQL($pattern, $context) { + return $this->getHasTypeCallSQL($pattern, $context, 1); + } + + function getIsiriCallSQL($pattern, $context) { + return $this->getHasTypeCallSQL($pattern, $context, 0); + } + + function getIsuriCallSQL($pattern, $context) { + return $this->getHasTypeCallSQL($pattern, $context, 0); + } + + function getStrCallSQL($pattern, $context) { + $sub_pattern = $pattern['args'][0]; + $sub_type = $sub_pattern['type']; + $m = 'get' . ucfirst($sub_type) . 'ExpressionSQL'; + if (method_exists($this, $m)) { + return $this->$m($sub_pattern, $context); + } + } + + function getFunctionCallSQL($pattern, $context) { + $f_uri = $pattern['uri']; + if (preg_match('/(integer|double|float|string)$/', $f_uri)) {/* skip conversions */ + $sub_pattern = $pattern['args'][0]; + $sub_type = $sub_pattern['type']; + $m = 'get' . ucfirst($sub_type) . 'ExpressionSQL'; + if (method_exists($this, $m)) { + return $this->$m($sub_pattern, $context); + } + } + } + + function getLangDatatypeCallSQL($pattern, $context) { + $r = ''; + if (isset($pattern['patterns'])) { /* proceed with first argument only (assumed as base type for type promotion) */ + $sub_pattern = array('args' => array($pattern['patterns'][0])); + return $this->getLangDatatypeCallSQL($sub_pattern, $context); + } + if (!isset($pattern['args'])) { + return 'FALSE'; + } + $sub_type = $pattern['args'][0]['type']; + if ($sub_type != 'var') { + return $this->getLangDatatypeCallSQL($pattern['args'][0], $context); + } + $var = $pattern['args'][0]['value']; + $info = $this->getVarTableInfos($var); + if (!$tbl = $info['table']) { + return ''; + } + $col = 'o_lang_dt'; + $tbl_alias = 'V_' . $tbl . '_' . $col . '.val'; + if (!in_array($tbl_alias, $this->index['sub_joins'])) { + $this->index['sub_joins'][] = $tbl_alias; + } + $op = $this->v('operator', '', $pattern); + $r = trim($op . ' ' . $tbl_alias); + return $r; + } + + function getDatatypeCallSQL($pattern, $context) { + return '/* datatype call */ ' . $this->getLangDatatypeCallSQL($pattern, $context); + } + + function getLangCallSQL($pattern, $context) { + return '/* language call */ ' . $this->getLangDatatypeCallSQL($pattern, $context); + } + + function getLangmatchesCallSQL($pattern, $context) { + if (count($pattern['args']) == 2) { + $arg_1 = $pattern['args'][0]; + $arg_2 = $pattern['args'][1]; + $sub_r_1 = $this->getBuiltInCallSQL($arg_1, $context);/* adds value join */ + $sub_r_2 = $this->getExpressionSQL($arg_2, $context); + $op = $this->v('operator', '', $pattern); + if (preg_match('/^([\"\'])([^\'\"]+)/', $sub_r_2, $m)) { + if ($m[2] == '*') { + $r = ($op == '!') ? 'NOT (' . $sub_r_1 . ' REGEXP "^[a-zA-Z\-]+$"' . ')' : $sub_r_1 . ' REGEXP "^[a-zA-Z\-]+$"'; + } + else { + $r = ($op == '!') ? $sub_r_1 . ' NOT LIKE ' . $m[1] . $m[2] . '%' . $m[1] : $sub_r_1 . ' LIKE ' . $m[1] . $m[2] . '%' . $m[1]; + } + } + else { + $r = ($op == '!') ? $sub_r_1 . ' NOT LIKE CONCAT(' . $sub_r_2 . ', "%")' : $sub_r_1 . ' LIKE CONCAT(' . $sub_r_2 . ', "%")'; + } + return $r; + } + return ''; + } + + function getSametermCallSQL($pattern, $context) { + if (count($pattern['args']) == 2) { + $arg_1 = $pattern['args'][0]; + $arg_2 = $pattern['args'][1]; + $sub_r_1 = $this->getExpressionSQL($arg_1, 'sameterm'); + $sub_r_2 = $this->getExpressionSQL($arg_2, 'sameterm'); + $op = $this->v('operator', '', $pattern); + $r = $sub_r_1 . ' ' . $op . '= ' . $sub_r_2; + return $r; + } + return ''; + } + + function getRegexCallSQL($pattern, $context) { + $ac = count($pattern['args']); + if ($ac >= 2) { + foreach ($pattern['args'] as $i => $arg) { + $var = 'sub_r_' . ($i + 1); + $$var = $this->getExpressionSQL($arg, $context, '', 'regex'); + } + $sub_r_3 = (isset($sub_r_3) && preg_match('/[\"\'](.+)[\"\']/', $sub_r_3, $m)) ? strtolower($m[1]) : ''; + $op = ($this->v('operator', '', $pattern) == '!') ? ' NOT' : ''; + if (!$sub_r_1 || !$sub_r_2) return ''; + $is_simple_search = preg_match('/^[\(\"]+(\^)?([a-z0-9\_\-\s]+)(\$)?[\)\"]+$/is', $sub_r_2, $m); + $is_simple_search = preg_match('/^[\(\"]+(\^)?([^\\\*\[\]\}\{\(\)\"\'\?\+\.]+)(\$)?[\)\"]+$/is', $sub_r_2, $m); + $is_o_search = preg_match('/o\.val\)*$/', $sub_r_1); + /* fulltext search (may have "|") */ + if ($is_simple_search && $is_o_search && !$op && (strlen($m[2]) > 8) && $this->store->hasFulltextIndex()) { + /* MATCH variations */ + if (($val_parts = preg_split('/\|/', $m[2]))) { + return 'MATCH(' . trim($sub_r_1, '()') . ') AGAINST("' . join(' ', $val_parts) . '")'; + } + else { + return 'MATCH(' . trim($sub_r_1, '()') . ') AGAINST("' . $m[2] . '")'; + } + } + if (preg_match('/\|/', $sub_r_2)) $is_simple_search = 0; + /* LIKE */ + if ($is_simple_search && ($sub_r_3 == 'i')) { + $sub_r_2 = $m[1] ? $m[2] : '%' . $m[2]; + $sub_r_2 .= isset($m[3]) && $m[3] ? '' : '%'; + return $sub_r_1 . $op . ' LIKE "' . $sub_r_2 . '"'; + } + /* REGEXP */ + $opt = ($sub_r_3 == 'i') ? '' : 'BINARY '; + return $sub_r_1 . $op . ' REGEXP ' . $opt . $sub_r_2; + } + return ''; + } + + /* */ + + function getGROUPSQL() { + $r = ''; + $nl = "\n"; + $infos = $this->v('group_infos', array(), $this->infos['query']); + foreach ($infos as $info) { + $var = $info['value']; + if ($tbl_infos = $this->getVarTableInfos($var, 0)) { + $tbl_alias = $tbl_infos['table_alias']; + $r .= $r ? ', ' : 'GROUP BY '; + $r .= $tbl_alias; + } + } + $hr = ''; + foreach ($this->index['havings'] as $having) { + $hr .= $hr ? ' AND' : ' HAVING'; + $hr .= '(' . $having . ')'; + } + $r .= $hr; + return $r ? $nl . $r : $r; + } + + /* */ + + function getORDERSQL() { + $r = ''; + $nl = "\n"; + $infos = $this->v('order_infos', array(), $this->infos['query']); + foreach ($infos as $info) { + $type = $info['type']; + $ms = array('expression' => 'getExpressionSQL', 'built_in_call' => 'getBuiltInCallSQL', 'function_call' => 'getFunctionCallSQL'); + $m = isset($ms[$type]) ? $ms[$type] : 'get' . ucfirst($type) . 'ExpressionSQL'; + if (method_exists($this, $m)) { + $sub_r = '(' . $this->$m($info, 'order') . ')'; + $sub_r .= $this->v('direction', '', $info) == 'desc' ? ' DESC' : ''; + $r .= $r ? ',' .$nl . $sub_r : $sub_r; + } + } + return $r ? $nl . 'ORDER BY ' . $r : ''; + } + + /* */ + + function getLIMITSQL() { + $r = ''; + $nl = "\n"; + $limit = $this->v('limit', -1, $this->infos['query']); + $offset = $this->v('offset', -1, $this->infos['query']); + if ($limit != -1) { + $offset = ($offset == -1) ? 0 : mysql_real_escape_string($offset, $this->store->getDBCon()); + $r = 'LIMIT ' . $offset . ',' . $limit; + } + elseif ($offset != -1) { + $r = 'LIMIT ' . mysql_real_escape_string($offset, $this->store->getDBCon()) . ',999999999999'; /* mysql doesn't support stand-alone offsets .. */ + } + return $r ? $nl . $r : ''; + } + + /* */ + + function getValueSQL($q_tbl, $q_sql) { + $r = ''; + /* result vars */ + $vars = $this->infos['query']['result_vars']; + $nl = "\n"; + $v_tbls = array('JOIN' => array(), 'LEFT JOIN' => array()); + $vc = 1; + foreach ($vars as $var) { + $var_name = $var['var']; + $r .= $r ? ',' . $nl . ' ' : ' '; + $col = ''; + $tbl = ''; + if ($var_name != '*') { + if (in_array($var_name, $this->infos['null_vars'])) { + if (isset($this->initial_index['vars'][$var_name])) { + $col = $this->initial_index['vars'][$var_name][0]['col']; + $tbl = $this->initial_index['vars'][$var_name][0]['table']; + } + if (isset($this->initial_index['graph_vars'][$var_name])) { + $col = 'g'; + $tbl = $this->initial_index['graph_vars'][$var_name][0]['table']; + } + } + elseif (isset($this->index['vars'][$var_name])) { + $col = $this->index['vars'][$var_name][0]['col']; + $tbl = $this->index['vars'][$var_name][0]['table']; + } + } + if ($var['aggregate']) { + $r .= 'TMP.`' . $var['alias'] . '`'; + } + else { + $join_type = in_array($tbl, array_merge($this->index['from'], $this->index['join'])) ? 'JOIN' : 'LEFT JOIN';/* val may be NULL */ + $v_tbls[$join_type][] = array('t_col' => $col, 'q_col' => $var_name, 'vc' => $vc); + $r .= 'V' . $vc . '.val AS `' . $var_name . '`'; + if (in_array($col, array('s', 'o'))) { + if (strpos($q_sql, '`' . $var_name . ' type`')) { + $r .= ', ' . $nl . ' TMP.`' . $var_name . ' type` AS `' . $var_name . ' type`'; + //$r .= ', ' . $nl . ' CASE TMP.`' . $var_name . ' type` WHEN 2 THEN "literal" WHEN 1 THEN "bnode" ELSE "uri" END AS `' . $var_name . ' type`'; + } + else { + $r .= ', ' . $nl . ' NULL AS `' . $var_name . ' type`'; + } + } + $vc++; + if ($col == 'o') { + $v_tbls[$join_type][] = array('t_col' => 'id', 'q_col' => $var_name . ' lang_dt', 'vc' => $vc); + if (strpos($q_sql, '`' . $var_name . ' lang_dt`')) { + $r .= ', ' .$nl. ' V' . $vc . '.val AS `' . $var_name . ' lang_dt`'; + $vc++; + } + else { + $r .= ', ' .$nl. ' NULL AS `' . $var_name . ' lang_dt`'; + } + } + } + } + if (!$r) $r = '*'; + /* from */ + $r .= $nl . 'FROM (' . $q_tbl . ' TMP)'; + foreach (array('JOIN', 'LEFT JOIN') as $join_type) { + foreach ($v_tbls[$join_type] as $v_tbl) { + $tbl = $this->getValueTable($v_tbl['t_col']); + $var_name = preg_replace('/^([^\s]+)(.*)$/', '\\1', $v_tbl['q_col']); + $cur_join_type = in_array($var_name, $this->infos['null_vars']) ? 'LEFT JOIN' : $join_type; + if (!strpos($q_sql, '`' . $v_tbl['q_col'].'`')) continue; + $r .= $nl . ' ' . $cur_join_type . ' ' . $tbl . ' V' . $v_tbl['vc'] . ' ON ( + (V' . $v_tbl['vc'] . '.id = TMP.`' . $v_tbl['q_col'].'`) + )'; + } + } + /* create pos columns, id needed */ + if ($this->v('order_infos', array(), $this->infos['query'])) { + $r .= $nl . ' ORDER BY _pos_'; + } + return 'SELECT' . $nl . $r; + } + + /* */ + +} + + diff --git a/arc2-2.2.4/store/ARC2_StoreSemHTMLLoader.php b/arc2-2.2.4/store/ARC2_StoreSemHTMLLoader.php new file mode 100755 index 0000000..941093e --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreSemHTMLLoader.php @@ -0,0 +1,36 @@ +extractRDF(); + } + + function addT($t) { + $this->caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreTableManager.php b/arc2-2.2.4/store/ARC2_StoreTableManager.php new file mode 100755 index 0000000..cc171ca --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreTableManager.php @@ -0,0 +1,290 @@ +engine_type = $this->v('store_engine_type', 'MyISAM', $this->a); + } + + /* */ + + function getTableOptionsCode() { + $v = $this->getDBVersion(); + $r = ""; + $r .= (($v < '04-01-00') && ($v >= '04-00-18')) ? 'ENGINE' : (($v >= '04-01-02') ? 'ENGINE' : 'TYPE'); + $r .= "=" . $this->engine_type; + $r .= ($v >= '04-00-00') ? " CHARACTER SET utf8" : ""; + $r .= ($v >= '04-01-00') ? " COLLATE utf8_unicode_ci" : ""; + $r .= " DELAY_KEY_WRITE = 1"; + return $r; + } + + /* */ + + function createTables() { + $con = $this->getDBCon(); + if(!$this->createTripleTable()) { + return $this->addError('Could not create "triple" table (' . mysql_error($con) . ').'); + } + if(!$this->createG2TTable()) { + return $this->addError('Could not create "g2t" table (' . mysql_error($con) . ').'); + } + if(!$this->createID2ValTable()) { + return $this->addError('Could not create "id2val" table (' . mysql_error($con) . ').'); + } + if(!$this->createS2ValTable()) { + return $this->addError('Could not create "s2val" table (' . mysql_error($con) . ').'); + } + if(!$this->createO2ValTable()) { + return $this->addError('Could not create "o2val" table (' . mysql_error($con) . ').'); + } + if(!$this->createSettingTable()) { + return $this->addError('Could not create "setting" table (' . mysql_error($con) . ').'); + } + return 1; + } + + /* */ + + function createTripleTable($suffix = 'triple') { + /* keep in sync with merge def in StoreQueryHandler ! */ + $indexes = $this->v('store_indexes', array('sp (s,p)', 'os (o,s)', 'po (p,o)'), $this->a); + $index_code = $indexes ? 'KEY ' . join(', KEY ', $indexes) . ', ' : ''; + $sql = " + CREATE TABLE IF NOT EXISTS " . $this->getTablePrefix() . $suffix . " ( + t mediumint UNSIGNED NOT NULL, + s mediumint UNSIGNED NOT NULL, + p mediumint UNSIGNED NOT NULL, + o mediumint UNSIGNED NOT NULL, + o_lang_dt mediumint UNSIGNED NOT NULL, + o_comp char(35) NOT NULL, /* normalized value for ORDER BY operations */ + s_type tinyint(1) NOT NULL default 0, /* uri/bnode => 0/1 */ + o_type tinyint(1) NOT NULL default 0, /* uri/bnode/literal => 0/1/2 */ + misc tinyint(1) NOT NULL default 0, /* temporary flags */ + UNIQUE KEY (t), " . $index_code . " KEY (misc) + ) ". $this->getTableOptionsCode() . " + "; + return mysql_query($sql, $this->getDBCon()); + } + + function extendTripleTableColumns($suffix = 'triple') { + $sql = " + ALTER TABLE " . $this->getTablePrefix() . $suffix . " + MODIFY t int(10) UNSIGNED NOT NULL, + MODIFY s int(10) UNSIGNED NOT NULL, + MODIFY p int(10) UNSIGNED NOT NULL, + MODIFY o int(10) UNSIGNED NOT NULL, + MODIFY o_lang_dt int(10) UNSIGNED NOT NULL + "; + return mysql_query($sql, $this->getDBCon()); + } + + /* */ + + function createG2TTable() { + $sql = " + CREATE TABLE IF NOT EXISTS " . $this->getTablePrefix() . "g2t ( + g mediumint UNSIGNED NOT NULL, + t mediumint UNSIGNED NOT NULL, + UNIQUE KEY gt (g,t), KEY tg (t,g) + ) ". $this->getTableOptionsCode() . " + "; + return mysql_query($sql, $this->getDBCon()); + } + + function extendG2tTableColumns($suffix = 'g2t') { + $sql = " + ALTER TABLE " . $this->getTablePrefix() . $suffix . " + MODIFY g int(10) UNSIGNED NOT NULL, + MODIFY t int(10) UNSIGNED NOT NULL + "; + return mysql_query($sql, $this->getDBCon()); + } + + /* */ + + function createID2ValTable() { + $sql = " + CREATE TABLE IF NOT EXISTS " . $this->getTablePrefix() . "id2val ( + id mediumint UNSIGNED NOT NULL, + misc tinyint(1) NOT NULL default 0, + val text NOT NULL, + val_type tinyint(1) NOT NULL default 0, /* uri/bnode/literal => 0/1/2 */ + UNIQUE KEY (id,val_type), KEY v (val(64)) + ) ". $this->getTableOptionsCode() . " + "; + return mysql_query($sql, $this->getDBCon()); + } + + function extendId2valTableColumns($suffix = 'id2val') { + $sql = " + ALTER TABLE " . $this->getTablePrefix() . $suffix . " + MODIFY id int(10) UNSIGNED NOT NULL + "; + return mysql_query($sql, $this->getDBCon()); + } + + /* */ + + function createS2ValTable() { + //$indexes = 'UNIQUE KEY (id), KEY vh (val_hash), KEY v (val(64))'; + $indexes = 'UNIQUE KEY (id), KEY vh (val_hash)'; + $sql = " + CREATE TABLE IF NOT EXISTS " . $this->getTablePrefix() . "s2val ( + id mediumint UNSIGNED NOT NULL, + misc tinyint(1) NOT NULL default 0, + val_hash char(32) NOT NULL, + val text NOT NULL, + " . $indexes . " + ) " . $this->getTableOptionsCode() . " + "; + return mysql_query($sql, $this->getDBCon()); + } + + function extendS2valTableColumns($suffix = 's2val') { + $sql = " + ALTER TABLE " . $this->getTablePrefix() . $suffix . " + MODIFY id int(10) UNSIGNED NOT NULL + "; + return mysql_query($sql, $this->getDBCon()); + } + + /* */ + + function createO2ValTable() { + /* object value index, e.g. "KEY v (val(64))" and/or "FULLTEXT KEY vft (val)" */ + $val_index = $this->v('store_object_index', 'KEY v (val(64))', $this->a); + if ($val_index) $val_index = ', ' . ltrim($val_index, ','); + $sql = " + CREATE TABLE IF NOT EXISTS " . $this->getTablePrefix() . "o2val ( + id mediumint UNSIGNED NOT NULL, + misc tinyint(1) NOT NULL default 0, + val_hash char(32) NOT NULL, + val text NOT NULL, + UNIQUE KEY (id), KEY vh (val_hash)" . $val_index . " + ) ". $this->getTableOptionsCode() . " + "; + return mysql_query($sql, $this->getDBCon()); + } + + function extendO2valTableColumns($suffix = 'o2val') { + $sql = " + ALTER TABLE " . $this->getTablePrefix() . $suffix . " + MODIFY id int(10) UNSIGNED NOT NULL + "; + return mysql_query($sql, $this->getDBCon()); + } + + /* */ + + function createSettingTable() { + $sql = " + CREATE TABLE IF NOT EXISTS " . $this->getTablePrefix() . "setting ( + k char(32) NOT NULL, + val text NOT NULL, + UNIQUE KEY (k) + ) ". $this->getTableOptionsCode() . " + "; + return mysql_query($sql, $this->getDBCon()); + } + + /* */ + + function extendColumns() { + $con = $this->getDBCon(); + $tbl_prefix = $this->getTablePrefix(); + $tbls = $this->getTables(); + foreach ($tbls as $suffix) { + if (preg_match('/^(triple|g2t|id2val|s2val|o2val)/', $suffix, $m)) { + $mthd = 'extend' . ucfirst($m[1]) . 'TableColumns'; + $this->$mthd($suffix); + } + } + } + + /* */ + + function splitTables() { + $old_ps = $this->getSetting('split_predicates', array()); + $new_ps = $this->retrieveSplitPredicates(); + $add_ps = array_diff($new_ps, $old_ps); + $del_ps = array_diff($old_ps, $new_ps); + $final_ps = array(); + foreach ($del_ps as $p) { + if (!$this->unsplitPredicate($p)) $final_ps[] = $p; + } + foreach ($add_ps as $p) { + if ($this->splitPredicate($p)) $final_ps[] = $p; + } + $this->setSetting('split_predicates', $new_ps); + } + + function unsplitPredicate($p) { + $suffix = 'triple_' . abs(crc32($p)); + $old_tbl = $this->getTablePrefix() . $suffix; + $new_tbl = $this->getTablePrefix() . 'triple'; + $p_id = $this->getTermID($p, 'p'); + $con = $this->getDBCon(); + $sql = ' + INSERT IGNORE INTO ' . $new_tbl .' + SELECT * FROM ' . $old_tbl . ' WHERE ' . $old_tbl . '.p = ' . $p_id . ' + '; + if ($rs = mysql_query($sql, $con)) { + mysql_query('DROP TABLE ' . $old_tbl, $con); + return 1; + } + else { + return 0; + } + } + + function splitPredicate($p) { + $suffix = 'triple_' . abs(crc32($p)); + $this->createTripleTable($suffix); + $old_tbl = $this->getTablePrefix() . 'triple'; + $new_tbl = $this->getTablePrefix() . $suffix; + $p_id = $this->getTermID($p, 'p'); + $con = $this->getDBCon(); + $sql = ' + INSERT IGNORE INTO ' . $new_tbl .' + SELECT * FROM ' . $old_tbl . ' WHERE ' . $old_tbl . '.p = ' . $p_id . ' + '; + if ($rs = mysql_query($sql, $con)) { + mysql_query('DELETE FROM ' . $old_tbl . ' WHERE ' . $old_tbl . '.p = ' . $p_id, $con); + return 1; + } + else { + mysql_query('DROP TABLE ' . $new_tbl, $con); + return 0; + } + } + + function retrieveSplitPredicates() { + $r = $this->split_predicates; + $limit = $this->max_split_tables - count($r); + $q = 'SELECT ?p COUNT(?p) AS ?pc WHERE { ?s ?p ?o } GROUP BY ?p ORDER BY DESC(?pc) LIMIT ' . $limit; + $rows = $this->query($q, 'rows'); + foreach ($rows as $row) { + $r[] = $row['p']; + } + return $r; + } + + /* */ + +} diff --git a/arc2-2.2.4/store/ARC2_StoreTurtleLoader.php b/arc2-2.2.4/store/ARC2_StoreTurtleLoader.php new file mode 100755 index 0000000..f12d3b0 --- /dev/null +++ b/arc2-2.2.4/store/ARC2_StoreTurtleLoader.php @@ -0,0 +1,32 @@ +caller->addT($t['s'], $t['p'], $t['o'], $t['s_type'], $t['o_type'], $t['o_datatype'], $t['o_lang']); + $this->t_count++; + } + + /* */ + +} diff --git a/arc2-2.2.4/tests/ARC2_TestCase.php b/arc2-2.2.4/tests/ARC2_TestCase.php new file mode 100755 index 0000000..7faa9eb --- /dev/null +++ b/arc2-2.2.4/tests/ARC2_TestCase.php @@ -0,0 +1,13 @@ +data_store = $data_store; + } + + function __init() { + parent::__init(); + $this->store = $this->caller; + ARC2::inc('Reader'); + $this->reader = new ARC2_Reader($this->a, $this); + } + + /* */ + + function runTest($id) { + $type = $this->getTestType($id); + $m = 'run' . $type; + $r = method_exists($this, $m) ? $this->$m($id) : array('pass' => 0, 'info' => 'not supported'); + sleep(1); + return $r; + } + + /* */ + + function getTestType($id) { + $q = 'SELECT ?type WHERE { <' .$id. '> a ?type . }'; + $qr = $this->store->query($q); + $r = isset($qr['result']['rows'][0]) ? $qr['result']['rows'][0]['type'] : '#QueryEvaluationTest'; + $r = preg_replace('/^.*\#([^\#]+)$/', '$1', $r); + return $r; + } + + /* */ + + function getFile($url) { + $fname = 'f' . crc32($url) . '.txt'; + if (!file_exists('tmp/' . $fname)) { + $r = ''; + if (!isset($this->reader)) { + $this->reader = new ARC2_Reader($this->a, $this); + } + $this->reader->activate($url); + while ($d = $this->reader->readStream()) { + $r .= $d; + } + $this->reader->closeStream(); + unset($this->reader); + $fp = @fopen('tmp/' . $fname, "w"); + @fwrite($fp, $r); + @fclose($fp); + return $r; + } + return file_get_contents('tmp/' . $fname); + } + + function runPositiveSyntaxTest($id) { + $nl = "\n"; + $r = ''; + /* get action */ + $q = ' + PREFIX mf: . + SELECT DISTINCT ?action WHERE { <' .$id. '> mf:action ?action . } + '; + $qr = $this->store->query($q); + $action = $qr['result']['rows'][0]['action']; + /* get code */ + $q = $this->getFile($action); + /* parse */ + ARC2::inc('SPARQLPlusParser'); + $parser = new ARC2_SPARQLPlusParser($this->a, $this); + $parser->parse($q, $action); + $infos = $parser->getQueryInfos(); + $rest = $parser->getUnparsedCode(); + $errors = $parser->getErrors(); + $r .= $nl . '
' . htmlspecialchars($q) . '
' . $nl ; + if ($errors || $rest) { + $pass = 0; + $r .= htmlspecialchars($nl . $nl . print_r($errors, 1) . $nl . print_r($rest, 1)); + } + else { + $pass = 1; + $r .= htmlspecialchars($nl . $nl . print_r($infos, 1)); + } + return array('pass' => $pass, 'info' => $r); + } + + /* */ + + function runNegativeSyntaxTest($id) { + $nl = "\n"; + $r = ''; + /* get action */ + $q = ' + PREFIX mf: . + SELECT DISTINCT ?action WHERE { <' .$id. '> mf:action ?action . } + '; + $qr = $this->store->query($q); + $action = $qr['result']['rows'][0]['action']; + /* get code */ + $q = $this->getFile($action); + /* parse */ + ARC2::inc('SPARQLPlusParser'); + $parser = new ARC2_SPARQLPlusParser($this->a, $this); + $parser->parse($q, $action); + $infos = $parser->getQueryInfos(); + $rest = $parser->getUnparsedCode(); + $errors = $parser->getErrors(); + $r .= $nl . '
' . htmlspecialchars($q) . '
' . $nl ; + if ($errors || $rest) { + $pass = 1; + $r .= htmlspecialchars($nl . $nl . print_r($errors, 1) . $nl . print_r($rest, 1)); + } + else { + $pass = 0; + $r .= htmlspecialchars($nl . $nl . print_r($infos, 1)); + } + return array('pass' => $pass, 'info' => $r); + } + + /* */ + + function runQueryEvaluationTest($id) { + $nl = "\n"; + $r = ''; + /* get action */ + $q = ' + PREFIX mf: . + PREFIX qt: . + SELECT DISTINCT ?query ?data ?graph_data ?result WHERE { + <' .$id. '> mf:action ?action ; + mf:result ?result . + ?action qt:query ?query . + OPTIONAL { + ?action qt:data ?data . + } + OPTIONAL { + ?action qt:graphData ?graph_data . + } + } + '; + $qr = $this->store->query($q); + $rows = $qr['result']['rows']; + $infos = array(); + foreach (array('query', 'data', 'result', 'graph_data') as $var) { + $infos[$var] = array(); + $infos[$var . '_value'] = array(); + foreach ($rows as $row) { + if (isset($row[$var])) { + if (!in_array($row[$var], $infos[$var])) { + $infos[$var][] = $row[$var]; + $infos[$var . '_value'][] = $this->getFile($row[$var]); + } + } + } + $$var = $infos[$var]; + ${$var . '_value'} = $infos[$var . '_value']; + if (count($infos[$var]) == 1) { + $$var = $infos[$var][0]; + ${$var . '_value'} = $infos[$var . '_value'][0]; + } + if ($$var && ($var != '-result')) { + //echo '
' . $$var . $nl . $nl . htmlspecialchars(${$var . '_value'}) . '

'; + } + } + /* query infos */ + ARC2::inc('SPARQLPlusParser'); + $parser = new ARC2_SPARQLPlusParser($this->a, $this); + $parser->parse($query_value, $query); + $infos = $parser->getQueryInfos(); + $rest = $parser->getUnparsedCode(); + $errors = $parser->getErrors(); + $q_type = !$errors ? $infos['query']['type'] : ''; + /* add data */ + $dsets = array(); + $gdsets = array(); + if ($data) { + $dsets = is_array($data) ? array_merge($dsets, $data) : array_merge($dsets, array($data)); + } + if ($graph_data) { + $gdsets = is_array($graph_data) ? array_merge($gdsets, $graph_data) : array_merge($gdsets, array($graph_data)); + } + if (!$dsets && !$gdsets) { + foreach ($infos['query']['dataset'] as $set) { + if ($set['named']) { + $gdsets[] = $set['graph']; + } + else { + $dsets[] = $set['graph']; + } + } + } + $store = $this->data_store; + $store->reset(); + foreach ($dsets as $graph) { + $qr = $store->query('LOAD <' .$graph. '>'); + } + foreach ($gdsets as $graph) { + $qr = $store->query('LOAD <' .$graph. '> INTO <' .$graph. '>'); + } + /* run query */ + if ($query) { + $sql = $store->query($query_value, 'sql', $query); + $qr = $store->query($query_value, '', $query); + $qr_result = $qr['result']; + if ($q_type == 'select') { + $qr_result = $this->adjustBnodes($qr['result'], $id); + } + elseif ($q_type == 'construct') { + $ser = ARC2::getTurtleSerializer($this->a); + $qr_result = $ser->getSerializedIndex($qr_result); + } + } + //echo '
query result: ' . $nl . htmlspecialchars(print_r($qr_result, 1)) . '
'; + if (!$query || $errors || $rest) { + return array('pass' => 0, 'info' => 'query could not be parsed' . htmlspecialchars($query_value)); + } + $m = 'isSame' . $q_type . 'Result'; + $sub_r = $this->$m($qr_result, $result_value, $result, $id); + $pass = $sub_r['pass']; + if (in_array($id, array( + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/sort/manifest#dawg-sort-6', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/sort/manifest#dawg-sort-8', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/sort/manifest#dawg-sort-builtin', + ))) { + $pass = 0; /* manually checked 2007-09-18 */ + } + if (in_array($id, array( + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/sort/manifest#dawg-sort-function', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/reduced/manifest#reduced-1', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/reduced/manifest#reduced-2', + ))) { + $pass = 1; /* manually checked 2007-11-28 */ + } + $pass_info = $sub_r['info']; + $info = print_r($pass_info, 1) . $nl; + $info .= '
sql: ' . $nl . htmlspecialchars($sql['result']) . '
'; + $info .= $pass ? '' : print_r($graph_data, 1) . $nl . htmlspecialchars(print_r($graph_data_value, 1)) . '
'; + $info .= $pass ? '' : print_r($data, 1) . $nl . htmlspecialchars(print_r($data_value, 1)) . '
'; + $info .= $pass ? '' : $query . $nl . htmlspecialchars($query_value) . '
'; + $info .= $pass ? '' : '
query result: ' . $nl . htmlspecialchars(print_r($qr_result, 1)) . '
' . '
'; + $info .= $pass ? '' : print_r($infos, 1); + return array('pass' => $pass, 'info' => $info); + } + + /* */ + + function isSameSelectResult($qr, $result, $result_base) { + if (strpos($result, 'http://www.w3.org/2001/sw/DataAccess/tests/result-set#')) { + $parser = ARC2::getRDFParser($this->a); + $parser->parse($result_base, $result); + $index = $parser->getSimpleIndex(0); + //echo '
' . print_r($index, 1) .'
'; + $valid_qr = $this->buildTurtleSelectQueryResult($index); + } + else { + $parser = ARC2::getSPARQLXMLResultParser($this->a); + $parser->parse('', $result); + $valid_qr = $parser->getStructure(); + } + if (isset($valid_qr['boolean'])) { + $pass = $valid_qr['boolean'] == $this->v('boolean', '', $qr); + } + else { + $pass = 1; + if (count($valid_qr['variables']) != count($qr['variables'])) { + $pass = 0; + } + if (count($valid_qr['rows']) != count($qr['rows'])) { + $pass = 0; + } + if ($pass) { + foreach ($valid_qr['variables'] as $var) { + if (!in_array($var, $qr['variables'])) { + $pass = 0; + break; + } + } + } + if ($pass) { + $index = $this->buildArrayHashIndex($qr['rows']); + $valid_index = $this->buildArrayHashIndex($valid_qr['rows']); + if (($diff = array_diff($index, $valid_index)) || ($diff = array_diff($valid_index, $index))) { + $pass = 0; + //echo '
' . print_r($diff, 1) . '
'; + } + } + } + return array('pass' => $pass, 'info' => $valid_qr); + } + + /* */ + + function isSameConstructResult($qr, $result, $result_base, $test) { + $parser = ARC2::getRDFParser($this->a); + $parser->parse('', $result); + $valid_triples = $parser->getTriples(); + $parser = ARC2::getRDFParser($this->a); + $parser->parse('', $qr); + $triples = $parser->getTriples(); + $info = '
' . print_r($valid_triples, 1) .'
'; + $info = ''; + + //echo '
' . print_r($index, 1) .'
'; + $pass = 0; + if (in_array($test, array(/* manually checked 2007-09-21 */ + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/construct/manifest#construct-1', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/construct/manifest#construct-2', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/construct/manifest#construct-3', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/construct/manifest#construct-4', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/construct/manifest#construct-5', + ))) { + $pass = 1; + } + return array('pass' => $pass, 'info' => $valid_triples); + } + + /* */ + + function isSameAskResult($qr, $result, $result_base) { + if (preg_match('/(true|false)\.(ttl|n3)$/', $result_base, $m)) { + $valid_r = $m[1]; + } + else { + $valid_r = preg_match('/boolean\>([^\<]+)/s', $result, $m) ? trim($m[1]) : '-'; + } + $r = ($qr === true) ? 'true' : 'false'; + $pass = ($r == $valid_r) ? 1 : 0; + return array('pass' => $pass, 'info' => $valid_r); + } + + /* */ + + function buildTurtleSelectQueryResult($index) { + $rs = 'http://www.w3.org/2001/sw/DataAccess/tests/result-set#'; + $rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + $r = array('variables' => array(), 'rows' => array()); + foreach ($index as $node => $props) { + $types = $this->v($rdf . 'type', array(), $props); + foreach ($types as $type) { + if ($type['value'] == $rs . 'ResultSet') { + $vars = $this->v($rs . 'resultVariable', array(), $props); + foreach ($vars as $var) { + $r['variables'][] = $var['value']; + } + } + } + $bindings = $this->v($rs . 'binding', array(), $props); + if ($bindings) { + $row = array(); + foreach ($bindings as $binding) { + $binding_id = $binding['value']; + $var = $index[$binding_id][$rs . 'variable'][0]['value']; + $val = $index[$binding_id][$rs . 'value'][0]['value']; + $val_type = $index[$binding_id][$rs . 'value'][0]['type']; + //$val_type = preg_match('/literal/', $val_type) ? 'literal' : $val_type; + $row[$var] = $val; + $row[$var . ' type'] = $val_type; + if ($dt = $this->v('datatype', 0, $index[$binding_id][$rs . 'value'][0])) { + $row[$var . ' datatype'] = $dt; + } + if ($lang = $this->v('lang', 0, $index[$binding_id][$rs . 'value'][0])) { + $row[$var . ' lang'] = $lang; + } + } + $r['rows'][] = $row; + } + } + return $r; + } + + /* */ + + function buildArrayHashIndex($rows) { + $r = array(); + foreach ($rows as $row) { + $hash = ''; + ksort($row); + foreach ($row as $k => $v) { + $hash .= is_numeric($k) ? '' : ' ' . md5($k) . ' ' . md5($v); + } + $r[] = $hash; + } + return $r; + } + + /* */ + + function adjustBnodes($result, $data) { + $mappings = array( + '_:b1371233574_bob' => '_:b10', + '_:b1114277307_alice' => '_:b1f', + '_:b1368422168_eve' => '_:b20', + '_:b1638119969_fred' => '_:b21', + + '_:b288335586_a' => array( + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#no-distinct-3' => '_:b0', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-3' => '_:b0', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-9' => '_:b0', + 'http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#no-distinct-9' => '_:b0', + 'default' => '_:bn5', + ), + ); + if (isset($result['rows'])) { + foreach ($result['rows'] as $i => $row) { + foreach ($result['variables'] as $var) { + if (isset($row[$var]) && isset($mappings[$row[$var]])) { + if (is_array($mappings[$row[$var]])) { + $result['rows'][$i][$var] = isset($mappings[$row[$var]][$data]) ? $mappings[$row[$var]][$data] : $mappings[$row[$var]]['default']; + } + else { + $result['rows'][$i][$var] = $mappings[$row[$var]]; + } + } + } + } + } + return $result; + } + +} diff --git a/arc2-2.2.4/tests/data/atom/feed.atom b/arc2-2.2.4/tests/data/atom/feed.atom new file mode 100755 index 0000000..446c131 --- /dev/null +++ b/arc2-2.2.4/tests/data/atom/feed.atom @@ -0,0 +1,20 @@ + + + + Example Feed + + 2003-12-13T18:30:02Z + + John Doe + + urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 + + + Atom-Powered Robots Run Amok + + urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + 2003-12-13T18:30:02Z + Some text. + + + \ No newline at end of file diff --git a/arc2-2.2.4/tests/data/json/crunchbase-facebook.js b/arc2-2.2.4/tests/data/json/crunchbase-facebook.js new file mode 100755 index 0000000..9974559 --- /dev/null +++ b/arc2-2.2.4/tests/data/json/crunchbase-facebook.js @@ -0,0 +1,450 @@ +{"name": "Facebook", + "permalink": "facebook", + "homepage_url": "http://facebook.com", + "blog_url": "http://blog.facebook.com", + "blog_feed_url": "http://blog.facebook.com/atom.php", + "category_code": "web", + "number_of_employees": 450, + "founded_year": 2004, + "founded_month": 2, + "founded_day": 1, + "deadpooled_year": null, + "deadpooled_month": null, + "deadpooled_day": null, + "deadpooled_url": "", + "tag_list": "social, facebook, college, students, profiles, network, socialnetwork, socialmedia, platform", + "email_address": "", + "phone_number": "", + "overview": "\u003Cp\u003EOn February 4th, 2004 \u003Ca href=\"http://www.crunchbase.com/person/mark-zuckerberg\" title=\"Mark Zuckerberg\"\u003EMark Zuckerberg\u003C/a\u003E launched The Facebook, a social network that was at the time exclusively for Harvard students. It was a huge hit, in 2 weeks, half of the student body at Harvard had signed up. Other schools in the Boston area began demanding a Facebook network. Zuckerberg immediately recruited his friends \u003Ca href=\"http://www.crunchbase.com/person/dustin-moskovitz\" title=\"Dustin Moskowitz\"\u003EDustin Moskowitz\u003C/a\u003E and Chris Hughes to help build Facebook, and within four months, Facebook added 30 more college networks. \u003C/p\u003E\n\n\u003Cp\u003EThe original idea for the term Facebook came from Zuckerberg\u0026#8217;s high school (Phillips Exeter Academy). The Exeter Face Book was passed around to every student as a way for students to get to know their classmates for the following year. It was a physical paper book until Zuckerberg brought it to the internet.\u003C/p\u003E\n\n\u003Cp\u003EWith this success, Zuckerberg, Moskowitz and Hughes moved out to Palo Alto for the summer and rented a sublet. A few weeks later, Zuckerberg ran into the former cofounder of Napster, Sean Parker. Parker soon moved in to Zuckerberg\u0026#8217;s apartment and they began working together. Parker provided the introduction to their first investor, Peter Thiel, cofounder of PayPal and managing partner of the Founders Fund. Thiel invested $500,000 into Facebook. \u003C/p\u003E\n\n\u003Cp\u003EWith millions more users, Friendster \u003Ca href=\"http://www.techcrunch.com/2006/12/12/yahoos-project-fraternity-docs-leaked/\" title=\"attempted\"\u003Eattempted\u003C/a\u003E to acquire the company for $10 million in mid 2004. Facebook turned down the offer and subsequently received $12.7 million in funding from Accel Partners, at a valuation of \u003Ca href=\"http://www.techcrunch.com/2005/09/07/85-of-college-students-use-facebook/\" title=\"around $100 million\"\u003Earound $100 million\u003C/a\u003E. Facebook continued to grow, opening up to high school students in September 2005 and adding an immensely popular photo sharing feature the next month. The next spring, Facebook received $25 million in funding from Greylock Partners and Meritech Capital, as well as previous investors Accel Partners and Peter Thiel. The pre-money valuation for this deal was about $525 million. Facebook subsequently \u003Ca href=\"http://www.techcrunch.com/2006/04/26/facebook-goes-beyond-college-high-school-markets/\" title=\"opened\"\u003Eopened\u003C/a\u003E up to work networks, eventually amassing over 20,000 work networks. Finally in September 2006, Facebook \u003Ca href=\"http://www.techcrunch.com/2006/09/26/facebook-just-launched-open-registrations/\" title=\"opened\"\u003Eopened\u003C/a\u003E to anyone with an email address. \u003C/p\u003E\n\n\u003Cp\u003EIn the summer of 2006, Yahoo \u003Ca href=\"http://www.techcrunch.com/2006/09/21/facebook-and-yahoo-in-acquisition-talks-for-1-billion/\" title=\"attempted to acquire\"\u003Eattempted to acquire\u003C/a\u003E the company for $1 billion dollars. \u003Ca href=\"http://www.wired.com/techbiz/startups/news/2007/09/ff_facebook\" title=\"Reports\" rel=\"nofollow\"\u003EReports\u003C/a\u003E actually indicated that Zuckerberg made a verbal agreement to sell Facebook to Yahoo. A few days later when Yahoo\u0026#8217;s stock price took a dive, the offer was lowered to $800 million and Zuckerberg walked away from the deal. Yahoo later \u003Ca href=\"http://www.techcrunch.com/2006/12/12/yahoos-project-fraternity-docs-leaked/\" title=\"offered\"\u003Eoffered\u003C/a\u003E $1 billion again, this time Zuckerberg turned Yahoo down and earned instant notoriety as the \u0026#8220;kid\u0026#8221; who turned down a billion. This was not the first time Zuckerberg turned down an acquisition offer; Viacom had previously \u003Ca href=\"http://www.techcrunch.com/2006/03/28/facebook-is-doing-the-skype-dance/\" title=\"unsuccessfully\"\u003Eunsuccessfully\u003C/a\u003E attempted to acquire the company for $750 million in March, 2006. \u003C/p\u003E\n\n\u003Cp\u003EOne sour note for Facebook has been the \u003Ca href=\"http://www.techcrunch.com/2007/07/16/the-ghost-of-zuckerbergs-past-may-haunt-facebook-ipo/\" title=\"controversy\"\u003Econtroversy\u003C/a\u003E with social network Uconnect. The founders of Uconnect, former classmates of Mark Zuckerberg at Harvard, allege that Zuckerberg stole their original source code for Facebook. The ordeal has \u003Ca href=\"http://www.techcrunch.com/2007/10/10/facebook-vs-connectu-facebook-makes-untrue-assertions-claims-connectu/\" title=\"gone to court\"\u003Egone to court\u003C/a\u003E, but is still unresolved. \u003C/p\u003E\n\n\u003Cp\u003ENotwithstanding this lingering controversy, Facebook\u0026#8217;s growth in the fall of 2007 was staggering. Over 1 million new users signed up every week, 200,000 daily, totaling over 50 million active users. Facebook received 40 billion page views a month. Long gone were the days of Facebook as a social network for college students. 11% of users are over the age of 35, and the fastest growing demographic is users over 30. Facebook has also seen huge growth internationally; 15% of the user base is in Canada. Facebook users\u0026#8217; \u003Ca href=\"http://www.techcrunch.com/2007/11/13/i-just-cant-be-a-college-student-without-facebook/\" title=\"passion\"\u003Epassion\u003C/a\u003E, or \u003Ca href=\"http://www.techcrunch.com/2007/03/09/career-advice-dont-choose-facebook-over-your-job/\" title=\"addiction\"\u003Eaddiction\u003C/a\u003E, to the site is unparalleled: more than half use the product every single day and users spend an average of 19 minutes a day on Facebook. Facebook is 6th most trafficked site in the US and top photo sharing site with \u003Ca href=\"http://www.techcrunch.com/2007/11/13/2-billion-photos-on-flickr/\" title=\"4.1 billion photos uploaded\"\u003E4.1 billion photos uploaded\u003C/a\u003E. \u003C/p\u003E\n\n\u003Cp\u003EBased on these types of numbers, \u003Ca href=\"http://www.techcrunch.com/2007/10/24/facebook-takes-the-microsoft-money-and-runs/\" title=\"Microsoft invested\"\u003EMicrosoft invested\u003C/a\u003E $240 million into Facebook for 1.6 percent of the company in October 2007. This meant a valuation of over $15 billion, making Facebook the \u003Ca href=\"http://www.techcrunch.com/2007/10/25/perspective-facebook-is-now-5th-most-valuable-us-internet-company/\" title=\"5th most valuable US Internet company\"\u003E5th most valuable US Internet company\u003C/a\u003E, yet with only $150 million in annual revenue. Many explained Microsoft\u0026#8217;s decision as being solely driven by the desire to outbid Google. \u003C/p\u003E\n\n\u003Cp\u003EFacebook\u0026#8217;s competitors include \u003Ca href=\"http://www.crunchbase.com/company/myspace\" title=\"MySpace\"\u003EMySpace\u003C/a\u003E, \u003Ca href=\"http://www.crunchbase.com/company/Bebo\" title=\"Bebo\"\u003EBebo\u003C/a\u003E, \u003Ca href=\"http://www.crunchbase.com/company/Friendster\" title=\"Friendster\"\u003EFriendster\u003C/a\u003E, \u003Ca href=\"http://www.crunchbase.com/company/LinkedIn\" title=\"LinkedIn\"\u003ELinkedIn\u003C/a\u003E, \u003Ca href=\"http://www.crunchbase.com/company/tagged\" title=\"Tagged\"\u003ETagged\u003C/a\u003E, \u003Ca href=\"http://www.techcrunch.com/2007/01/20/hi5-traffic-surges-may-be-second-largest-social-network/\" title=\"Hi5\"\u003EHi5\u003C/a\u003E, \u003Ca href=\"http://www.techcrunch.com/2006/09/25/a-look-at-piczo-and-its-competitors/\" title=\"Piczo\"\u003EPiczo\u003C/a\u003E, and \u003Ca href=\"http://www.techcrunch.com/2007/10/30/details-revealed-google-opensocial-to-be-common-apis-for-building-social-apps/\" title=\"Open Social\"\u003EOpen Social\u003C/a\u003E. \u003C/p\u003E\n\n\u003Cp\u003E\u003Cimg src=\"http://farm3.static.flickr.com/2059/2046940872_73672f2007.jpg\" alt=\"Facebook Traffic\"/\u003E\u003C/p\u003E", + "image": + {"available_sizes": + [[[150, + 56], + "assets/images/resized/0000/4552/4552v2-max-150x150.jpg"], + [[250, + 94], + "assets/images/resized/0000/4552/4552v2-max-250x250.jpg"], + [[450, + 169], + "assets/images/resized/0000/4552/4552v2-max-450x450.jpg"]], + "attribution": null}, + "products": + [{"name": "Facebook Platform", + "permalink": "facebook-platform"}, + {"name": "Facebook News Feed", + "permalink": "facebook-news-feed"}, + {"name": "Facebook Chat", + "permalink": "facebook-chat"}, + {"name": "Facebook Connect", + "permalink": "facebook-connect"}, + {"name": "Facebook iPhone App", + "permalink": "facebook-iphone-app"}], + "relationships": + [{"is_past": false, + "title": "Founder and CEO, Board Of Directors", + "person": + {"first_name": "Mark", + "last_name": "Zuckerberg", + "permalink": "mark-zuckerberg"}}, + {"is_past": false, + "title": "Co-founder and VP Engineering", + "person": + {"first_name": "Dustin", + "last_name": "Moskovitz", + "permalink": "dustin-moskovitz"}}, + {"is_past": true, + "title": "Chief Revenue Officer, VP of Operations", + "person": + {"first_name": "Owen", + "last_name": "Van Natta", + "permalink": "owen-van-natta"}}, + {"is_past": true, + "title": "VP of Product Management", + "person": + {"first_name": "Matt", + "last_name": "Cohler", + "permalink": "matt-cohler"}}, + {"is_past": false, + "title": "Co-founder", + "person": + {"first_name": "Chris", + "last_name": "Hughes", + "permalink": "chris-hughes"}}, + {"is_past": false, + "title": "VP of Product Marketing", + "person": + {"first_name": "Chamath", + "last_name": "Palihapitiya", + "permalink": "chamath-palihapitiya"}}, + {"is_past": false, + "title": "CFO", + "person": + {"first_name": "Gideon", + "last_name": "Yu", + "permalink": "gideon-yu"}}, + {"is_past": true, + "title": "CTO", + "person": + {"first_name": "Adam", + "last_name": "D'Angelo", + "permalink": "adam-d-angelo"}}, + {"is_past": false, + "title": "COO", + "person": + {"first_name": "Sheryl", + "last_name": "Sandberg", + "permalink": "sheryl-sandberg"}}, + {"is_past": false, + "title": "Senior Platform Manager", + "person": + {"first_name": "Dave", + "last_name": "Morin", + "permalink": "dave-morin"}}, + {"is_past": false, + "title": "Director of Business Development", + "person": + {"first_name": "Ethan", + "last_name": "Beard", + "permalink": "ethan-beard"}}, + {"is_past": false, + "title": "Chief Privacy Officer", + "person": + {"first_name": "Chris", + "last_name": "Kelly", + "permalink": "chris-kelly"}}, + {"is_past": false, + "title": "", + "person": + {"first_name": "Justin", + "last_name": "Rosenstein", + "permalink": "justin-rosenstein"}}, + {"is_past": false, + "title": "VP of Technical Operations", + "person": + {"first_name": "Jonathan", + "last_name": "Heiliger", + "permalink": "jonathan-heiliger"}}, + {"is_past": false, + "title": "Director Platform Product Marketing", + "person": + {"first_name": "Ben", + "last_name": "Ling", + "permalink": "ben-ling"}}, + {"is_past": false, + "title": "Product Lead for Facebook Platform", + "person": + {"first_name": "Ruchi", + "last_name": "Sanghvi", + "permalink": "ruchi-sanghvi"}}, + {"is_past": false, + "title": "Board Of Directors", + "person": + {"first_name": "Jim", + "last_name": "Breyer", + "permalink": "jim-breyer"}}, + {"is_past": false, + "title": "VP of Communications and Public Policy", + "person": + {"first_name": "Elliot", + "last_name": "Schrage", + "permalink": "elliot-schrage"}}, + {"is_past": false, + "title": "Board Of Directors", + "person": + {"first_name": "Peter", + "last_name": "Thiel", + "permalink": "peter-thiel"}}, + {"is_past": false, + "title": "Observer to Board of Directors", + "person": + {"first_name": "David", + "last_name": "Sze", + "permalink": "david-sze"}}, + {"is_past": true, + "title": "President, Board of Directors", + "person": + {"first_name": "Sean", + "last_name": "Parker", + "permalink": "sean-parker"}}, + {"is_past": false, + "title": "Board of directors", + "person": + {"first_name": "Marc", + "last_name": "Andreessen", + "permalink": "marc-andreessen"}}], + "competitions": + [{"competitor": + {"name": "MySpace", + "permalink": "myspace"}}, + {"competitor": + {"name": "Friendster", + "permalink": "friendster"}}, + {"competitor": + {"name": "Slide", + "permalink": "slide"}}, + {"competitor": + {"name": "Zvents", + "permalink": "zvents"}}, + {"competitor": + {"name": "FriendFeed", + "permalink": "friendfeed"}}, + {"competitor": + {"name": "Qik", + "permalink": "qik"}}, + {"competitor": + {"name": "hi5", + "permalink": "hi5"}}, + {"competitor": + {"name": "Photobucket", + "permalink": "photobucket"}}, + {"competitor": + {"name": "Webshots", + "permalink": "webshots"}}, + {"competitor": + {"name": "Flickr", + "permalink": "flickr"}}, + {"competitor": + {"name": "Spokeo", + "permalink": "spokeo"}}, + {"competitor": + {"name": "HOT or NOT", + "permalink": "hotornot"}}, + {"competitor": + {"name": "Piczo", + "permalink": "piczo"}}, + {"competitor": + {"name": "Zyb", + "permalink": "zyb"}}, + {"competitor": + {"name": "Multiply", + "permalink": "multiply"}}, + {"competitor": + {"name": "YouTube", + "permalink": "youtube"}}, + {"competitor": + {"name": "badoo", + "permalink": "badoo"}}, + {"competitor": + {"name": "openPeople", + "permalink": "openpeople"}}, + {"competitor": + {"name": "Bigsight Media Group", + "permalink": "bigsight-media-group"}}, + {"competitor": + {"name": "Xiaonei", + "permalink": "xiaonei"}}, + {"competitor": + {"name": "Daikana", + "permalink": "daikana"}}, + {"competitor": + {"name": "Bebo", + "permalink": "bebo"}}, + {"competitor": + {"name": "AOL", + "permalink": "aol"}}, + {"competitor": + {"name": "CityIN", + "permalink": "cityin"}}, + {"competitor": + {"name": "Xanga", + "permalink": "xanga"}}, + {"competitor": + {"name": "Spleak", + "permalink": "spleak"}}, + {"competitor": + {"name": "yuwie", + "permalink": "yuwie"}}, + {"competitor": + {"name": "Rekatu", + "permalink": "rekatu"}}, + {"competitor": + {"name": "5icampus", + "permalink": "5icampus"}}, + {"competitor": + {"name": "Tagged", + "permalink": "tagged"}}], + "providerships": + [{"title": "", + "is_past": false, + "provider": + {"name": "OutCast Communications", + "permalink": "outcast-communications"}}, + {"title": "Public Relations", + "is_past": false, + "provider": + {"name": "Blanc \u0026 Otus", + "permalink": "blanc-otus"}}], + "funding_rounds": + [{"round_code": "angel", + "source_url": "", + "source_description": "", + "raised_amount": 500000.0, + "raised_currency_code": "USD", + "funded_year": 2004, + "funded_month": 9, + "funded_day": 1, + "investments": + [{"company": null, + "financial_org": + {"name": "The Founders Fund", + "permalink": "founders-fund"}, + "person": null}]}, + {"round_code": "a", + "source_url": "http://www.techcrunch.com/2007/11/02/jim-breyer-extra-500-million-round-for-facebook-a-total-fiction/", + "source_description": "Jim Breyer: Extra $500 Million Round For Facebook A \u201cTotal Fiction\u201d", + "raised_amount": 12700000.0, + "raised_currency_code": "USD", + "funded_year": 2005, + "funded_month": 5, + "funded_day": 1, + "investments": + [{"company": null, + "financial_org": + {"name": "Accel Partners", + "permalink": "accel-partners"}, + "person": null}]}, + {"round_code": "b", + "source_url": "http://www.facebook.com/press/info.php?factsheet", + "source_description": "Facebook Funding", + "raised_amount": 27500000.0, + "raised_currency_code": "USD", + "funded_year": 2006, + "funded_month": 4, + "funded_day": 1, + "investments": + [{"company": null, + "financial_org": + {"name": "Greylock", + "permalink": "greylock"}, + "person": null}, + {"company": null, + "financial_org": + {"name": "Meritech Capital Partners", + "permalink": "meritech-capital-partners"}, + "person": null}, + {"company": null, + "financial_org": null, + "person": + {"first_name": "Peter", + "last_name": "Thiel", + "permalink": "peter-thiel"}}]}, + {"round_code": "c", + "source_url": "http://www.techcrunch.com/2007/10/24/liveblogging-the-facebook-press-conference/#more-10260", + "source_description": "Liveblogging The Facebook Press Conference", + "raised_amount": 300000000.0, + "raised_currency_code": "USD", + "funded_year": 2007, + "funded_month": 10, + "funded_day": 1, + "investments": + [{"company": + {"name": "Microsoft", + "permalink": "microsoft"}, + "financial_org": null, + "person": null}, + {"company": null, + "financial_org": null, + "person": + {"first_name": "Li", + "last_name": "Ka-shing", + "permalink": "li-ka-shing"}}, + {"company": null, + "financial_org": null, + "person": + {"first_name": "Marc", + "last_name": "Samwer", + "permalink": "marc-samwer"}}, + {"company": null, + "financial_org": null, + "person": + {"first_name": "Oliver", + "last_name": "Samwer", + "permalink": "oliver-samwer"}}, + {"company": null, + "financial_org": null, + "person": + {"first_name": "Alexander", + "last_name": "Samwer", + "permalink": "alexander-samwer"}}]}, + {"round_code": "c", + "source_url": "http://www.marketwatch.com/news/story/hong-kong-tycoon-li-raises/story.aspx?guid=%7BE4097AA2-9EA3-4773-9100-456E68EE1C9A%7D", + "source_description": "", + "raised_amount": 40000000.0, + "raised_currency_code": "USD", + "funded_year": 2008, + "funded_month": 3, + "funded_day": null, + "investments": + [{"company": null, + "financial_org": null, + "person": + {"first_name": "Li", + "last_name": "Ka-shing", + "permalink": "li-ka-shing"}}]}, + {"round_code": "c", + "source_url": "", + "source_description": "Reneigh is sexy", + "raised_amount": 15000000.0, + "raised_currency_code": "USD", + "funded_year": 2008, + "funded_month": 1, + "funded_day": 15, + "investments": + [{"company": null, + "financial_org": + {"name": "European Founders Fund", + "permalink": "european-founders-fund"}, + "person": null}]}, + {"round_code": "debt_round", + "source_url": "http://www.businessweek.com/technology/content/may2008/tc2008059_855064.htm", + "source_description": "", + "raised_amount": 100000000.0, + "raised_currency_code": "USD", + "funded_year": 2008, + "funded_month": 5, + "funded_day": null, + "investments": + [{"company": null, + "financial_org": + {"name": "TriplePoint Capital", + "permalink": "triplepoint-capital"}, + "person": null}]}], + "investments": + [], + "acquisition": null, + "acquisitions": + [{"price_amount": null, + "price_currency_code": "USD", + "term_code": "cash", + "source_url": null, + "source_description": null, + "acquired_year": 2007, + "acquired_month": 7, + "acquired_day": 1, + "company": + {"name": "Parakey", + "permalink": "parakey"}}], + "offices": + [{"description": null, + "address1": "156 University Avenue", + "address2": "", + "zip_code": "94301", + "city": "Palo Alto", + "state_code": "CA", + "country_code": "USA", + "latitude": 37.444173, + "longitude": -122.163294}], + "milestones": + [{"description": "Facebook adds comments to Mini-Feed", + "stoned_year": 2008, + "stoned_month": 6, + "stoned_day": 25, + "source_url": "http://venturebeat.com/2008/06/25/facebook-adds-comment-to-the-mini-feed-its-like-friendfeed-is-looking-in-the-mirror/", + "source_description": "Facebook adds comments to the Mini-Feed. It\u2019s like FriendFeed is looking in the mirror"}], + "ipo": null, + "video_embeds": + [{"embed_code": "\u003Cscript type=\"text/javascript\" src=\"http://www.podtech.net/player/popup.js\"\u003E\u003C/script\u003E\u003Cobject classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"450\" height=\"299\" id=\"player73536e08d3f742de9d31b25a319af359\" align=\"middle\"\u003E\u003Cparam name=\"allowScriptAccess\" value=\"always\" /\u003E\u003Cparam name=\"FlashVars\" value=\"content=http://media1.podtech.net/media/2007/09/PID012533/PodtechRandiZuckerberg2.flv\u0026totalTime=2149000\u0026permalink=http://www.podtech.net/home/4118/the-first-sister-of-facebook\u0026breadcrumb=73536e08d3f742de9d31b25a319af359\" height=\"299\" width=\"450\" /\u003E\u003Cparam name=\"movie\" value=\"http://www.podtech.net/player/podtech-player.swf?bc=73536e08d3f742de9d31b25a319af359\" /\u003E\u003Cparam name=\"quality\" value=\"high\" /\u003E\u003Cparam name=\"scale\" value=\"noscale\" /\u003E\u003Cparam name=\"bgcolor\" value=\"#000000\" /\u003E\u003Cembed name=\"player73536e08d3f742de9d31b25a319af359\" type=\"application/x-shockwave-flash\" src=\"http://www.podtech.net/player/podtech-player.swf?bc=73536e08d3f742de9d31b25a319af359\" flashvars=\"content=http://media1.podtech.net/media/2007/09/PID012533/PodtechRandiZuckerberg2.flv\u0026totalTime=2149000\u0026permalink=http://www.podtech.net/home/4118/the-first-sister-of-facebook\u0026breadcrumb=73536e08d3f742de9d31b25a319af359\" height=\"299\" width=\"450\" allowScriptAccess=\"always\" /\u003E\u003C/object\u003E\u003Cnoscript\u003EYour browser does not support JavaScript. This media can be viewed at http://www.podtech.net/home/4118/the-first-sister-of-facebook\u003C/noscript\u003E", + "description": "\u003Cp\u003ERobert Scoble\u2019s video from www.podtech.net/scobleshow:\u003C/p\u003E"}], + "external_links": + [{"external_url": "http://www.marketwatch.com/news/story/story.aspx?guid={E4097AA2-9EA3-4773-9100-456E68EE1C9A}", + "title": "Hong Kong tycoon Li raises personal Facebook investment above $100 mln"}]} \ No newline at end of file diff --git a/arc2-2.2.4/tests/data/json/sparql-select-result.json b/arc2-2.2.4/tests/data/json/sparql-select-result.json new file mode 100755 index 0000000..2276f3f --- /dev/null +++ b/arc2-2.2.4/tests/data/json/sparql-select-result.json @@ -0,0 +1,78 @@ +{ + "head": { + "link": [ + "http://www.w3.org/TR/rdf-sparql-XMLres/example.rq" + ], + "vars": [ + "x", + "hpage", + "name", + "mbox", + "age", + "blurb", + "friend" + ] + }, + "results": { + "bindings": [ + { + "x" : { + "type": "bnode", + "value": "r1" + }, + + "hpage" : { + "type": "uri", + "value": "http://work.example.org/alice/" + }, + + "name" : { + "type": "literal", + "value": "Alice" + }, + + "mbox" : { + "type": "literal", + "value": "" + }, + + "blurb" : { + "datatype": "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral", + "type": "typed-literal", + "value": "

My name is alice

" + }, + + "friend" : { + "type": "bnode", + "value": "r2" + } + },{ + "x" : { + "type": "bnode", + "value": "r2" + }, + + "hpage" : { + "type": "uri", + "value": "http://work.example.org/bob/" + }, + + "name" : { + "type": "literal", + "value": "Bob", + "xml:lang": "en" + }, + + "mbox" : { + "type": "uri", + "value": "mailto:bob@work.example.org" + }, + + "friend" : { + "type": "bnode", + "value": "r1" + } + } + ] + } + } diff --git a/arc2-2.2.4/tests/data/nt/test.nt b/arc2-2.2.4/tests/data/nt/test.nt new file mode 100755 index 0000000..3e52881 --- /dev/null +++ b/arc2-2.2.4/tests/data/nt/test.nt @@ -0,0 +1,78 @@ +# +# Copyright World Wide Web Consortium, (Massachusetts Institute of +# Technology, Institut National de Recherche en Informatique et en +# Automatique, Keio University). +# +# All Rights Reserved. +# +# Please see the full Copyright clause at +# +# +# Test file with a variety of legal N-Triples +# +# Dave Beckett - http://purl.org/net/dajobe/ +# +# $Id: test.nt,v 1.7 2003/10/06 15:52:19 dbeckett2 Exp $ +# +##################################################################### + +# comment lines + # comment line after whitespace +# empty blank line, then one with spaces and tabs + + + . +_:anon . + _:anon . +# spaces and tabs throughout: + . + +# line ending with CR NL (ASCII 13, ASCII 10) + . + +# 2 statement lines separated by single CR (ASCII 10) + . . + + +# All literal escapes + "simple literal" . + "backslash:\\" . + "dquote:\"" . + "newline:\n" . + "return\r" . + "tab:\t" . + +# Space is optional before final . + . + "x". + _:anon. + +# \u and \U escapes +# latin small letter e with acute symbol \u00E9 - 3 UTF-8 bytes #xC3 #A9 + "\u00E9" . +# Euro symbol \u20ac - 3 UTF-8 bytes #xE2 #x82 #xAC + "\u20AC" . +# resource18 test removed +# resource19 test removed +# resource20 test removed + +# XML Literals as Datatyped Literals + ""^^ . + " "^^ . + "x"^^ . + "\""^^ . + ""^^ . + "a "^^ . + "a c"^^ . + "a\n\nc"^^ . + "chat"^^ . +# resource28 test removed 2003-08-03 +# resource29 test removed 2003-08-03 + +# Plain literals with languages + "chat"@fr . + "chat"@en . + +# Typed Literals + "abc"^^ . +# resource33 test removed 2003-08-03 diff --git a/arc2-2.2.4/tests/data/rdfxml/planetrdf-bloggers.rdf b/arc2-2.2.4/tests/data/rdfxml/planetrdf-bloggers.rdf new file mode 100755 index 0000000..16e5b30 --- /dev/null +++ b/arc2-2.2.4/tests/data/rdfxml/planetrdf-bloggers.rdf @@ -0,0 +1,1439 @@ + + + + + +Planet RDF + + +Planet RDF site blog + + + + + + + + + + + + + + +AKSW Group - University of Leipzig + + +AKSW Group - University of Leipzig + + + + + + + + + + + + + + +Dean Allemang + + + +S is for Semantics by Dean Allemang + + + + + + + + + + + + + + +Zoltan Andrejkovics + + +Zoltan Andrejkovics + + + + + + + + + + + + + + +Al Baker +AlBaker_Dev + + +Linked Java by Al Baker + + + + + + + + + + + + + + +Dave Beckett +dajobe + + +Journalblog by Dave Beckett + + + + + + + + + + + + + + +Tim Berners-Leetimberners_lee + + +Tim Berners-Lee + + + + + + + + + + + + + + +Uldis BojarsCaptSolo + + +Uldis Bojars (Captain Solo) + + + + + + + + + + + + + + +John Breslin +johnbreslin + + +Cloudlands by John Breslin + + + + + + + + + + + + + + +Dan Brickley +danbri + + +danbri's foaf stories + + + + + + + + + + + + + + +Jeen Broekstra +jeenbroekstra + + +Rivuli by Jeen Broekstra + + + + + + + + + + + + + + +Dries Buytaertdries + + +Dries Buytaert - Semantic Web + + + + + + + + + + + + + + +Cambridge Semantics + + +Cambridge Semantics + + + + + + + + + + + + + + +Clark and Parsiacandp + + +Tales of a Semantic Web Consultancy by Clark and Parsia + + + + + + + + + + + + + + +Dan Connolly +dckc + + +Dan Connolly + + + + + + + + + + + + + + +Richard Cyganiakcygri + + +Richard Cyganiak + + + + + + + + + + + + + + +Datagraphdatagraph + + +Datagraph + + + + + + + + + + + + + + +Phil Dawesphildawes + + +Phil Dawes + + + + + + + + + + + + + + +Yves Raimond +moustaki + + +DBTune by Yves Raimond + + + + + + + + + + + + + + +DERI Galway + + +DERI Galway + + + + + + + + + + + + + + +DOAP Project + + +DOAP Project + + + + + + + + + + + + + + +Leigh Dodds +ldodds + + +Lost Boy by Leigh Dodds + + + + + + + + + + + + + + +Dublin Core Metadata InitiativeDublinCore + + +Dublin Core Metadata Initiative + + + + + + + + + + + + + + +Bob DuCharme +bobdc + + +bobdc.blog by Bob DuCharme + + + + + + + + + + + + + + +Edd Dumbill +edd + + +behind the times by Edd Dumbill + + + + + + + + + + + + + + +Ebiquity research group UMBC + + +Ebiquity research group UMBC + + + + + + + + + + + + + + +Dydradydradata + + +Dydra + + + + + + + + + + + + + + +EnAKTing project + + +EnAKTing project + + + + + + + + + + + + + + +Orri Erling + + +Orri Erling by + + + + + + + + + + + + + + +Lee FeigenbaumLeeFeigenbaum + + +Lee Feigenbaum + + + + + + + + + + + + + + +Sergio Fernández + + + +Sergio Fernández + + + + + + + + + + + + + + +FOAF Project + + +FOAF Project blog + + + + + + + + + + + + + + +Morten Frederiksen +mortenf + + +Binary Relations by Morten Frederiksen + + + + + + + + + + + + + + +Frederick Giasson + + +Frederick Giasson + + + + + + + + + + + + + + +John Goodwingothwin + + +John Goodwin + + + + + + + + + + + + + + +Richard Hancock + + + +3kbo by Richard Hancock + + + + + + + + + + + + + + +Michael Hausenblas +mhausenblas + + +Web of Data by Michael Hausenblas + + + + + + + + + + + + + + +Sandro Hawke +sandhawke + + + Decentralyze – Programming the Data Cloud by Sandro Hawke + + + + + + + + + + + + + + +Tom Heath +tommyh + + +Displacement Activities by Tom Heath + + + + + + + + + + + + + + +Ivan Hermanivan_herman + + +Ivan Herman + + + + + + + + + + + + + + +Kingsley Idehen +Kidehen + + +Data Space by Kingsley Idehen + + + + + + + + + + + + + + +Learn Linked Datalearnlinkeddata + + +Learn Linked Data + + + + + + + + + + + + + + +Talisnodalities + + +Nodalities by Talis + + + + + + + + + + + + + + +Seevlseevl + + +Seevl technology + + + + + + + + + + + + + + +Semantic Web Company (Austria)semwebcompany + + +Semantic Puzzle by Semantic Web Company (Austria) + + + + + + + + + + + + + + +SchemaWeb + + +SchemaWeb + + + + + + + + + + + + + + +Ora Lassila + + + +Wilbur-and-O by Ora Lassila + + + + + + + + + + + + + + +Peter Mika + + + +Tripletalk by Peter Mika + + + + + + + + + + + + + + +Andrew Matthews + + + +The Wandering Glitch 2 by Andrew Matthews + + + + + + + + + + + + + + +ZDNet Semantic Web by Paul MillerPaulMiller + + +ZDNet Semantic Web by Paul Miller + + + + + + + + + + + + + + +Libby Miller +libbymiller + + +Plan B by Libby Miller + + + + + + + + + + + + + + +Benjamin Nowack +bengee + + +bnode by Benjamin Nowack + + + + + + + + + + + + + + +Open Sahara blog + + +Open Sahara blog + + + + + + + + + + + + + + +Alexandre Passantterraces + + +Alexandre Passant + + + + + + + + + + + + + + +Davide Palmisano +dpalmisano + + +turn off the lights, please by Davide Palmisano + + + + + + + + + + + + + + +POWDER WG blog + + +POWDER WG blog + + + + + + + + + + + + + + +RDFa + + +RDFa + + + + + + + + + + + + + + +Dave Raggettdraggett + + +Dave Raggett + + + + + + + + + + + + + + +David Robillarddrobilla + + +David Robillard + + + + + + + + + + + + + + +RDF Resource Guide + + +Dave Beckett's RDF Resource Guide + + + + + + + + + + + + + + +Peter Shaw + + + +Shawfactor by Peter Shaw + + + + + + + + + + + + + + +schema.org + + +schema.org + + + + + + + + + + + + + + +Henry Story +bblfish + + +BabelFish by Henry Story + + + + + + + + + + + + + + +Jeni TennisonJeniT + + +Jeni Tennison - Musings + + + + + + + + + + + + + + +Tetherless World Constellation group RPIjahendler + + +Tetherless World Constellation group RPI + + + + + + + + + + + + + + +Elias Torres + + +Elias Torres + + + + + + + + + + + + + + +Sebastian Trueg + + + +Semantic Desktop by Sebastian Trueg + + + + + + + + + + + + + + +W3C Semantic Web News + + +W3C Semantic Web News + + + + + + + + + + + + + + +W3C Read Write Web Community Group + + +W3C Read Write Web Community Group Blog + + + + + + + + + + + + + + +W3C Blog Semantic Web News + + +W3C Blog Semantic Web News + + + + + + + + + + + + + + +Norm Walshndw + + +Norm Walsh + + + + + + + + + + + + + + +Mark Watsonmark_l_watson + + +Mark Watson + + + + + + + + + + + + + + +Danny Weitzner +djweitzner + + +Open Internet Policy by Danny Weitzner + + + + + + + + + + + + + + +Web of Data + + +Web of Data + + + + + + + + + + + + + + +Bill Roberts +billroberts + + +Web of Data by Bill Roberts + + + + + + + + + + + + + + +Web Semántica Hoy + + +Web Semántica Hoy + + + + + + + + + + + + + + +Gregory Williamskasei + + +Gregory Williams + + + + + + + + + + + + + + +Egon Willighagenegonwillighagen + + +chem-bla-ics by Egon Willighagen + + + + + + + + + + + + + + + diff --git a/arc2-2.2.4/tests/data/turtle/manifest.ttl b/arc2-2.2.4/tests/data/turtle/manifest.ttl new file mode 100755 index 0000000..a5f909e --- /dev/null +++ b/arc2-2.2.4/tests/data/turtle/manifest.ttl @@ -0,0 +1,2190 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Test named *subm* are (c) W3C and taken from the Turtle submission. + +@prefix rdf: . +@prefix rdfs: . +@prefix mf: . +@prefix qt: . + +@prefix rdft: . + +<> rdf:type mf:Manifest ; + rdfs:comment "Turtle tests" ; + mf:entries + ( + + # atomic tests + <#IRI_subject> + <#IRI_with_four_digit_numeric_escape> + <#IRI_with_eight_digit_numeric_escape> + <#IRI_with_all_punctuation> + <#bareword_a_predicate> + <#old_style_prefix> + <#SPARQL_style_prefix> + <#prefixed_IRI_predicate> + <#prefixed_IRI_object> + <#prefix_only_IRI> + <#prefix_with_PN_CHARS_BASE_character_boundaries> + <#prefix_with_non_leading_extras> + <#default_namespace_IRI> + <#prefix_reassigned_and_used> + <#reserved_escaped_localName> + <#percent_escaped_localName> + <#HYPHEN_MINUS_in_localName> + <#underscore_in_localName> + <#localname_with_COLON> + <#localName_with_assigned_nfc_bmp_PN_CHARS_BASE_character_boundaries> + <#localName_with_assigned_nfc_PN_CHARS_BASE_character_boundaries> + <#localName_with_nfc_PN_CHARS_BASE_character_boundaries> + <#localName_with_PN_CHARS_BASE_character_boundaries> + <#localName_with_leading_underscore> + <#localName_with_leading_digit> + <#localName_with_non_leading_extras> + <#old_style_base> + <#SPARQL_style_base> + <#labeled_blank_node_subject> + <#labeled_blank_node_object> + <#labeled_blank_node_with_PN_CHARS_BASE_character_boundaries> + <#labeled_blank_node_with_leading_underscore> + <#labeled_blank_node_with_leading_digit> + <#labeled_blank_node_with_non_leading_extras> + <#anonymous_blank_node_subject> + <#anonymous_blank_node_object> + <#sole_blankNodePropertyList> + <#blankNodePropertyList_as_subject> + <#blankNodePropertyList_as_object> + <#blankNodePropertyList_with_multiple_triples> + <#nested_blankNodePropertyLists> + <#blankNodePropertyList_containing_collection> + <#collection_subject> + <#collection_object> + <#empty_collection> + <#nested_collection> + <#first> + <#last> + <#LITERAL1> + <#LITERAL1_ascii_boundaries> + <#LITERAL1_with_UTF8_boundaries> + <#LITERAL1_all_controls> + <#LITERAL1_all_punctuation> + <#LITERAL_LONG1> + <#LITERAL_LONG1_ascii_boundaries> + <#LITERAL_LONG1_with_UTF8_boundaries> + <#LITERAL_LONG1_with_1_squote> + <#LITERAL_LONG1_with_2_squotes> + <#LITERAL2> + <#LITERAL2_ascii_boundaries> + <#LITERAL2_with_UTF8_boundaries> + <#LITERAL_LONG2> + <#LITERAL_LONG2_ascii_boundaries> + <#LITERAL_LONG2_with_UTF8_boundaries> + <#LITERAL_LONG2_with_1_squote> + <#LITERAL_LONG2_with_2_squotes> + <#literal_with_CHARACTER_TABULATION> + <#literal_with_BACKSPACE> + <#literal_with_LINE_FEED> + <#literal_with_CARRIAGE_RETURN> + <#literal_with_FORM_FEED> + <#literal_with_REVERSE_SOLIDUS> + <#literal_with_escaped_CHARACTER_TABULATION> + <#literal_with_escaped_BACKSPACE> + <#literal_with_escaped_LINE_FEED> + <#literal_with_escaped_CARRIAGE_RETURN> + <#literal_with_escaped_FORM_FEED> + <#literal_with_numeric_escape4> + <#literal_with_numeric_escape8> + <#IRIREF_datatype> + <#prefixed_name_datatype> + <#bareword_integer> + <#bareword_decimal> + <#bareword_double> + <#double_lower_case_e> + <#negative_numeric> + <#positive_numeric> + <#numeric_with_leading_0> + <#literal_true> + <#literal_false> + <#langtagged_non_LONG> + <#langtagged_LONG> + <#lantag_with_subtag> + <#objectList_with_two_objects> + <#predicateObjectList_with_two_objectLists> + <#repeated_semis_at_end> + <#repeated_semis_not_at_end> + + # original tests-ttl + <#turtle-syntax-file-01> + <#turtle-syntax-file-02> + <#turtle-syntax-file-03> + <#turtle-syntax-uri-01> + <#turtle-syntax-uri-02> + <#turtle-syntax-uri-03> + <#turtle-syntax-uri-04> + <#turtle-syntax-base-01> + <#turtle-syntax-base-02> + <#turtle-syntax-base-03> + <#turtle-syntax-base-04> + <#turtle-syntax-prefix-01> + <#turtle-syntax-prefix-02> + <#turtle-syntax-prefix-03> + <#turtle-syntax-prefix-04> + <#turtle-syntax-prefix-05> + <#turtle-syntax-prefix-06> + <#turtle-syntax-prefix-07> + <#turtle-syntax-prefix-08> + <#turtle-syntax-prefix-09> + <#turtle-syntax-string-01> + <#turtle-syntax-string-02> + <#turtle-syntax-string-03> + <#turtle-syntax-string-04> + <#turtle-syntax-string-05> + <#turtle-syntax-string-06> + <#turtle-syntax-string-07> + <#turtle-syntax-string-08> + <#turtle-syntax-string-09> + <#turtle-syntax-string-10> + <#turtle-syntax-string-11> + <#turtle-syntax-str-esc-01> + <#turtle-syntax-str-esc-02> + <#turtle-syntax-str-esc-03> + <#turtle-syntax-pname-esc-01> + <#turtle-syntax-pname-esc-02> + <#turtle-syntax-pname-esc-03> + <#turtle-syntax-bnode-01> + <#turtle-syntax-bnode-02> + <#turtle-syntax-bnode-03> + <#turtle-syntax-bnode-04> + <#turtle-syntax-bnode-05> + <#turtle-syntax-bnode-06> + <#turtle-syntax-bnode-07> + <#turtle-syntax-bnode-08> + <#turtle-syntax-bnode-09> + <#turtle-syntax-bnode-10> + <#turtle-syntax-number-01> + <#turtle-syntax-number-02> + <#turtle-syntax-number-03> + <#turtle-syntax-number-04> + <#turtle-syntax-number-05> + <#turtle-syntax-number-06> + <#turtle-syntax-number-07> + <#turtle-syntax-number-08> + <#turtle-syntax-number-09> + <#turtle-syntax-number-10> + <#turtle-syntax-number-11> + <#turtle-syntax-datatypes-01> + <#turtle-syntax-datatypes-02> + <#turtle-syntax-kw-01> + <#turtle-syntax-kw-02> + <#turtle-syntax-kw-03> + <#turtle-syntax-struct-01> + <#turtle-syntax-struct-02> + <#turtle-syntax-struct-03> + <#turtle-syntax-struct-04> + <#turtle-syntax-struct-05> + <#turtle-syntax-lists-01> + <#turtle-syntax-lists-02> + <#turtle-syntax-lists-03> + <#turtle-syntax-lists-04> + <#turtle-syntax-lists-05> + <#turtle-syntax-bad-uri-01> + <#turtle-syntax-bad-uri-02> + <#turtle-syntax-bad-uri-03> + <#turtle-syntax-bad-uri-04> + <#turtle-syntax-bad-uri-05> + <#turtle-syntax-bad-prefix-01> + <#turtle-syntax-bad-prefix-02> + <#turtle-syntax-bad-prefix-03> + <#turtle-syntax-bad-prefix-04> + <#turtle-syntax-bad-prefix-05> + <#turtle-syntax-bad-base-01> + <#turtle-syntax-bad-base-02> + <#turtle-syntax-bad-base-03> + <#turtle-syntax-bad-struct-01> + <#turtle-syntax-bad-struct-02> + <#turtle-syntax-bad-struct-03> + <#turtle-syntax-bad-struct-04> + <#turtle-syntax-bad-struct-05> + <#turtle-syntax-bad-struct-06> + <#turtle-syntax-bad-struct-07> + <#turtle-syntax-bad-kw-01> + <#turtle-syntax-bad-kw-02> + <#turtle-syntax-bad-kw-03> + <#turtle-syntax-bad-kw-04> + <#turtle-syntax-bad-kw-05> + <#turtle-syntax-bad-n3-extras-01> + <#turtle-syntax-bad-n3-extras-02> + <#turtle-syntax-bad-n3-extras-03> + <#turtle-syntax-bad-n3-extras-04> + <#turtle-syntax-bad-n3-extras-05> + <#turtle-syntax-bad-n3-extras-06> + <#turtle-syntax-bad-n3-extras-07> + <#turtle-syntax-bad-n3-extras-08> + <#turtle-syntax-bad-n3-extras-09> + <#turtle-syntax-bad-n3-extras-10> + <#turtle-syntax-bad-n3-extras-11> + <#turtle-syntax-bad-n3-extras-12> + <#turtle-syntax-bad-n3-extras-13> + <#turtle-syntax-bad-struct-08> + <#turtle-syntax-bad-struct-09> + <#turtle-syntax-bad-struct-10> + <#turtle-syntax-bad-struct-11> + <#turtle-syntax-bad-struct-12> + <#turtle-syntax-bad-struct-13> + <#turtle-syntax-bad-struct-14> + <#turtle-syntax-bad-struct-15> + <#turtle-syntax-bad-struct-16> + <#turtle-syntax-bad-struct-17> + <#turtle-syntax-bad-lang-01> + <#turtle-syntax-bad-esc-01> + <#turtle-syntax-bad-esc-02> + <#turtle-syntax-bad-esc-03> + <#turtle-syntax-bad-esc-04> + <#turtle-syntax-bad-pname-01> + <#turtle-syntax-bad-pname-02> + <#turtle-syntax-bad-pname-03> + <#turtle-syntax-bad-string-01> + <#turtle-syntax-bad-string-02> + <#turtle-syntax-bad-string-03> + <#turtle-syntax-bad-string-04> + <#turtle-syntax-bad-string-05> + <#turtle-syntax-bad-string-06> + <#turtle-syntax-bad-string-07> + <#turtle-syntax-bad-num-01> + <#turtle-syntax-bad-num-02> + <#turtle-syntax-bad-num-03> + <#turtle-syntax-bad-num-04> + <#turtle-syntax-bad-num-05> + <#turtle-eval-struct-01> + <#turtle-eval-struct-02> + <#turtle-subm-01> + <#turtle-subm-02> + <#turtle-subm-03> + <#turtle-subm-04> + <#turtle-subm-05> + <#turtle-subm-06> + <#turtle-subm-07> + <#turtle-subm-08> + <#turtle-subm-09> + <#turtle-subm-10> + <#turtle-subm-11> + <#turtle-subm-12> + <#turtle-subm-13> + <#turtle-subm-14> + <#turtle-subm-15> + <#turtle-subm-16> + <#turtle-subm-17> + <#turtle-subm-18> + <#turtle-subm-19> + <#turtle-subm-20> + <#turtle-subm-21> + <#turtle-subm-22> + <#turtle-subm-23> + <#turtle-subm-24> + <#turtle-subm-25> + <#turtle-subm-26> + <#turtle-subm-27> + <#turtle-eval-bad-01> + <#turtle-eval-bad-02> + <#turtle-eval-bad-03> + <#turtle-eval-bad-04> + + # tests from Dave Beckett + # http://www.w3.org/2011/rdf-wg/wiki/Turtle_Candidate_Recommendation_Comments#c28 + <#LITERAL_LONG2_with_REVERSE_SOLIDUS> + <#turtle-syntax-bad-LITERAL2_with_langtag_and_datatype> + <#two_LITERAL_LONG2s> + <#langtagged_LONG_with_subtag> + + # tests from David Robillard + # http://www.w3.org/2011/rdf-wg/wiki/Turtle_Candidate_Recommendation_Comments#c21 + <#turtle-syntax-bad-blank-label-dot-end> + <#turtle-syntax-bad-ln-dash-start> + <#turtle-syntax-bad-ln-escape-start> + <#turtle-syntax-bad-ln-escape> + <#turtle-syntax-bad-missing-ns-dot-end> + <#turtle-syntax-bad-missing-ns-dot-start> + <#turtle-syntax-bad-ns-dot-end> + <#turtle-syntax-bad-ns-dot-start> + <#turtle-syntax-bad-number-dot-in-anon> + <#turtle-syntax-blank-label> + <#turtle-syntax-ln-colons> + <#turtle-syntax-ln-dots> + <#turtle-syntax-ns-dots> + ) . + +# atomic tests +<#IRI_subject> rdf:type rdft:TestTurtleEval ; + mf:name "IRI_subject" ; + rdfs:comment "IRI subject" ; + mf:action ; + mf:result ; + . + +<#IRI_with_four_digit_numeric_escape> rdf:type rdft:TestTurtleEval ; + mf:name "IRI_with_four_digit_numeric_escape" ; + rdfs:comment "IRI with four digit numeric escape (\\u)" ; + mf:action ; + mf:result ; + . + +<#IRI_with_eight_digit_numeric_escape> rdf:type rdft:TestTurtleEval ; + mf:name "IRI_with_eight_digit_numeric_escape" ; + rdfs:comment "IRI with eight digit numeric escape (\\U)" ; + mf:action ; + mf:result ; + . + +<#IRI_with_all_punctuation> rdf:type rdft:TestTurtleEval ; + mf:name "IRI_with_all_punctuation" ; + rdfs:comment "IRI with all punctuation" ; + mf:action ; + mf:result ; + . + +<#bareword_a_predicate> rdf:type rdft:TestTurtleEval ; + mf:name "bareword_a_predicate" ; + rdfs:comment "bareword a predicate" ; + mf:action ; + mf:result ; + . + +<#old_style_prefix> rdf:type rdft:TestTurtleEval ; + mf:name "old_style_prefix" ; + rdfs:comment "old-style prefix" ; + mf:action ; + mf:result ; + . + +<#SPARQL_style_prefix> rdf:type rdft:TestTurtleEval ; + mf:name "SPARQL_style_prefix" ; + rdfs:comment "SPARQL-style prefix" ; + mf:action ; + mf:result ; + . + +<#prefixed_IRI_predicate> rdf:type rdft:TestTurtleEval ; + mf:name "prefixed_IRI_predicate" ; + rdfs:comment "prefixed IRI predicate" ; + mf:action ; + mf:result ; + . + +<#prefixed_IRI_object> rdf:type rdft:TestTurtleEval ; + mf:name "prefixed_IRI_object" ; + rdfs:comment "prefixed IRI object" ; + mf:action ; + mf:result ; + . + +<#prefix_only_IRI> rdf:type rdft:TestTurtleEval ; + mf:name "prefix_only_IRI" ; + rdfs:comment "prefix-only IRI (p:)" ; + mf:action ; + mf:result ; + . + +<#prefix_with_PN_CHARS_BASE_character_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "prefix_with_PN_CHARS_BASE_character_boundaries" ; + rdfs:comment "prefix with PN CHARS BASE character boundaries (prefix: AZazÀÖØöø...:)" ; + mf:action ; + mf:result ; + . + +<#prefix_with_non_leading_extras> rdf:type rdft:TestTurtleEval ; + mf:name "prefix_with_non_leading_extras" ; + rdfs:comment "prefix with_non_leading_extras (_:a·̀ͯ‿.⁀)" ; + mf:action ; + mf:result ; + . + +<#localName_with_assigned_nfc_bmp_PN_CHARS_BASE_character_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_assigned_nfc_bmp_PN_CHARS_BASE_character_boundaries" ; + rdfs:comment "localName with assigned, NFC-normalized, basic-multilingual-plane PN CHARS BASE character boundaries (p:AZazÀÖØöø...)" ; + mf:action ; + mf:result ; + . + +<#localName_with_assigned_nfc_PN_CHARS_BASE_character_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_assigned_nfc_PN_CHARS_BASE_character_boundaries" ; + rdfs:comment "localName with assigned, NFC-normalized PN CHARS BASE character boundaries (p:AZazÀÖØöø...)" ; + mf:action ; + mf:result ; + . + +<#localName_with_nfc_PN_CHARS_BASE_character_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_nfc_PN_CHARS_BASE_character_boundaries" ; + rdfs:comment "localName with nfc-normalize PN CHARS BASE character boundaries (p:AZazÀÖØöø...)" ; + mf:action ; + mf:result ; + . + +<#localName_with_PN_CHARS_BASE_character_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_PN_CHARS_BASE_character_boundaries" ; + rdfs:comment "localName with PN CHARS BASE character boundaries (p:AZazÀÖØöø...)" ; + mf:action ; + mf:result ; + . + +<#default_namespace_IRI> rdf:type rdft:TestTurtleEval ; + mf:name "default_namespace_IRI" ; + rdfs:comment "default namespace IRI (:ln)" ; + mf:action ; + mf:result ; + . + +<#prefix_reassigned_and_used> rdf:type rdft:TestTurtleEval ; + mf:name "prefix_reassigned_and_used" ; + rdfs:comment "prefix reassigned and used" ; + mf:action ; + mf:result ; + . + +<#reserved_escaped_localName> rdf:type rdft:TestTurtleEval ; + mf:name "reserved_escaped_localName" ; + rdfs:comment "reserved-escaped local name" ; + mf:action ; + mf:result ; + . + +<#percent_escaped_localName> rdf:type rdft:TestTurtleEval ; + mf:name "percent_escaped_localName" ; + rdfs:comment "percent-escaped local name" ; + mf:action ; + mf:result ; + . + +<#HYPHEN_MINUS_in_localName> rdf:type rdft:TestTurtleEval ; + mf:name "HYPHEN_MINUS_in_localName" ; + rdfs:comment "HYPHEN-MINUS in local name" ; + mf:action ; + mf:result ; + . + +<#underscore_in_localName> rdf:type rdft:TestTurtleEval ; + mf:name "underscore_in_localName" ; + rdfs:comment "underscore in local name" ; + mf:action ; + mf:result ; + . + +<#localname_with_COLON> rdf:type rdft:TestTurtleEval ; + mf:name "localname_with_COLON" ; + rdfs:comment "localname with COLON" ; + mf:action ; + mf:result ; + . + +<#localName_with_leading_underscore> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_leading_underscore" ; + rdfs:comment "localName with leading underscore (p:_)" ; + mf:action ; + mf:result ; + . + +<#localName_with_leading_digit> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_leading_digit" ; + rdfs:comment "localName with leading digit (p:_)" ; + mf:action ; + mf:result ; + . + +<#localName_with_non_leading_extras> rdf:type rdft:TestTurtleEval ; + mf:name "localName_with_non_leading_extras" ; + rdfs:comment "localName with_non_leading_extras (_:a·̀ͯ‿.⁀)" ; + mf:action ; + mf:result ; + . + +<#old_style_base> rdf:type rdft:TestTurtleEval ; + mf:name "old_style_base" ; + rdfs:comment "old-style base" ; + mf:action ; + mf:result ; + . + +<#SPARQL_style_base> rdf:type rdft:TestTurtleEval ; + mf:name "SPARQL_style_base" ; + rdfs:comment "SPARQL-style base" ; + mf:action ; + mf:result ; + . + +<#labeled_blank_node_subject> rdf:type rdft:TestTurtleEval ; + mf:name "labeled_blank_node_subject" ; + rdfs:comment "labeled blank node subject" ; + mf:action ; + mf:result ; + . + +<#labeled_blank_node_object> rdf:type rdft:TestTurtleEval ; + mf:name "labeled_blank_node_object" ; + rdfs:comment "labeled blank node object" ; + mf:action ; + mf:result ; + . + +<#labeled_blank_node_with_PN_CHARS_BASE_character_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "labeled_blank_node_with_PN_CHARS_BASE_character_boundaries" ; + rdfs:comment "labeled blank node with PN_CHARS_BASE character boundaries (_:AZazÀÖØöø...)" ; + mf:action ; + mf:result ; + . + +<#labeled_blank_node_with_leading_underscore> rdf:type rdft:TestTurtleEval ; + mf:name "labeled_blank_node_with_leading_underscore" ; + rdfs:comment "labeled blank node with_leading_underscore (_:_)" ; + mf:action ; + mf:result ; + . + +<#labeled_blank_node_with_leading_digit> rdf:type rdft:TestTurtleEval ; + mf:name "labeled_blank_node_with_leading_digit" ; + rdfs:comment "labeled blank node with_leading_digit (_:0)" ; + mf:action ; + mf:result ; + . + +<#labeled_blank_node_with_non_leading_extras> rdf:type rdft:TestTurtleEval ; + mf:name "labeled_blank_node_with_non_leading_extras" ; + rdfs:comment "labeled blank node with_non_leading_extras (_:a·̀ͯ‿.⁀)" ; + mf:action ; + mf:result ; + . + +<#anonymous_blank_node_subject> rdf:type rdft:TestTurtleEval ; + mf:name "anonymous_blank_node_subject" ; + rdfs:comment "anonymous blank node subject" ; + mf:action ; + mf:result ; + . + +<#anonymous_blank_node_object> rdf:type rdft:TestTurtleEval ; + mf:name "anonymous_blank_node_object" ; + rdfs:comment "anonymous blank node object" ; + mf:action ; + mf:result ; + . + +<#sole_blankNodePropertyList> rdf:type rdft:TestTurtleEval ; + mf:name "sole_blankNodePropertyList" ; + rdfs:comment "sole blankNodePropertyList [

] ." ; + mf:action ; + mf:result ; + . + +<#blankNodePropertyList_as_subject> rdf:type rdft:TestTurtleEval ; + mf:name "blankNodePropertyList_as_subject" ; + rdfs:comment "blankNodePropertyList as subject [ … ]

." ; + mf:action ; + mf:result ; + . + +<#blankNodePropertyList_as_object> rdf:type rdft:TestTurtleEval ; + mf:name "blankNodePropertyList_as_object" ; + rdfs:comment "blankNodePropertyList as object

[ … ] ." ; + mf:action ; + mf:result ; + . + +<#blankNodePropertyList_with_multiple_triples> rdf:type rdft:TestTurtleEval ; + mf:name "blankNodePropertyList_with_multiple_triples" ; + rdfs:comment "blankNodePropertyList with multiple triples [

; ]" ; + mf:action ; + mf:result ; + . + +<#nested_blankNodePropertyLists> rdf:type rdft:TestTurtleEval ; + mf:name "nested_blankNodePropertyLists" ; + rdfs:comment "nested blankNodePropertyLists [ [ ] ; ]" ; + mf:action ; + mf:result ; + . + +<#blankNodePropertyList_containing_collection> rdf:type rdft:TestTurtleEval ; + mf:name "blankNodePropertyList_containing_collection" ; + rdfs:comment "blankNodePropertyList containing collection [ ( … ) ]" ; + mf:action ; + mf:result ; + . + +<#collection_subject> rdf:type rdft:TestTurtleEval ; + mf:name "collection_subject" ; + rdfs:comment "collection subject" ; + mf:action ; + mf:result ; + . + +<#collection_object> rdf:type rdft:TestTurtleEval ; + mf:name "collection_object" ; + rdfs:comment "collection object" ; + mf:action ; + mf:result ; + . + +<#empty_collection> rdf:type rdft:TestTurtleEval ; + mf:name "empty_collection" ; + rdfs:comment "empty collection ()" ; + mf:action ; + mf:result ; + . + +<#nested_collection> rdf:type rdft:TestTurtleEval ; + mf:name "nested_collection" ; + rdfs:comment "nested collection (())" ; + mf:action ; + mf:result ; + . + +<#first> rdf:type rdft:TestTurtleEval ; + mf:name "first" ; + rdfs:comment "first, not last, non-empty nested collection" ; + mf:action ; + mf:result ; + . + +<#last> rdf:type rdft:TestTurtleEval ; + mf:name "last" ; + rdfs:comment "last, not first, non-empty nested collection" ; + mf:action ; + mf:result ; + . + +<#LITERAL1> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL1" ; + rdfs:comment "LITERAL1 'x'" ; + mf:action ; + mf:result ; + . + +<#LITERAL1_ascii_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL1_ascii_boundaries" ; + rdfs:comment "LITERAL1_ascii_boundaries '\\x00\\x09\\x0b\\x0c\\x0e\\x26\\x28...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL1_with_UTF8_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL1_with_UTF8_boundaries" ; + rdfs:comment "LITERAL1_with_UTF8_boundaries '\\x80\\x7ff\\x800\\xfff...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL1_all_controls> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL1_all_controls" ; + rdfs:comment "LITERAL1_all_controls '\\x00\\x01\\x02\\x03\\x04...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL1_all_punctuation> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL1_all_punctuation" ; + rdfs:comment "LITERAL1_all_punctuation '!\"#$%&()...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG1> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG1" ; + rdfs:comment "LITERAL_LONG1 '''x'''" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG1_ascii_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG1_ascii_boundaries" ; + rdfs:comment "LITERAL_LONG1_ascii_boundaries '\\x00\\x26\\x28...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG1_with_UTF8_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG1_with_UTF8_boundaries" ; + rdfs:comment "LITERAL_LONG1_with_UTF8_boundaries '\\x80\\x7ff\\x800\\xfff...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG1_with_1_squote> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG1_with_1_squote" ; + rdfs:comment "LITERAL_LONG1 with 1 squote '''a'b'''" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG1_with_2_squotes> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG1_with_2_squotes" ; + rdfs:comment "LITERAL_LONG1 with 2 squotes '''a''b'''" ; + mf:action ; + mf:result ; + . + +<#LITERAL2> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL2" ; + rdfs:comment "LITERAL2 \"x\"" ; + mf:action ; + mf:result ; + . + +<#LITERAL2_ascii_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL2_ascii_boundaries" ; + rdfs:comment "LITERAL2_ascii_boundaries '\\x00\\x09\\x0b\\x0c\\x0e\\x21\\x23...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL2_with_UTF8_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL2_with_UTF8_boundaries" ; + rdfs:comment "LITERAL2_with_UTF8_boundaries '\\x80\\x7ff\\x800\\xfff...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG2> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG2" ; + rdfs:comment "LITERAL_LONG2 \"\"\"x\"\"\"" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG2_ascii_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG2_ascii_boundaries" ; + rdfs:comment "LITERAL_LONG2_ascii_boundaries '\\x00\\x21\\x23...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG2_with_UTF8_boundaries> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG2_with_UTF8_boundaries" ; + rdfs:comment "LITERAL_LONG2_with_UTF8_boundaries '\\x80\\x7ff\\x800\\xfff...'" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG2_with_1_squote> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG2_with_1_squote" ; + rdfs:comment "LITERAL_LONG2 with 1 squote \"\"\"a\"b\"\"\"" ; + mf:action ; + mf:result ; + . + +<#LITERAL_LONG2_with_2_squotes> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG2_with_2_squotes" ; + rdfs:comment "LITERAL_LONG2 with 2 squotes \"\"\"a\"\"b\"\"\"" ; + mf:action ; + mf:result ; + . + +<#literal_with_CHARACTER_TABULATION> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_CHARACTER_TABULATION" ; + rdfs:comment "literal with CHARACTER TABULATION" ; + mf:action ; + mf:result ; + . + +<#literal_with_BACKSPACE> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_BACKSPACE" ; + rdfs:comment "literal with BACKSPACE" ; + mf:action ; + mf:result ; + . + +<#literal_with_LINE_FEED> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_LINE_FEED" ; + rdfs:comment "literal with LINE FEED" ; + mf:action ; + mf:result ; + . + +<#literal_with_CARRIAGE_RETURN> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_CARRIAGE_RETURN" ; + rdfs:comment "literal with CARRIAGE RETURN" ; + mf:action ; + mf:result ; + . + +<#literal_with_FORM_FEED> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_FORM_FEED" ; + rdfs:comment "literal with FORM FEED" ; + mf:action ; + mf:result ; + . + +<#literal_with_REVERSE_SOLIDUS> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_REVERSE_SOLIDUS" ; + rdfs:comment "literal with REVERSE SOLIDUS" ; + mf:action ; + mf:result ; + . + +<#literal_with_escaped_CHARACTER_TABULATION> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_escaped_CHARACTER_TABULATION" ; + rdfs:comment "literal with escaped CHARACTER TABULATION" ; + mf:action ; + mf:result ; + . + +<#literal_with_escaped_BACKSPACE> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_escaped_BACKSPACE" ; + rdfs:comment "literal with escaped BACKSPACE" ; + mf:action ; + mf:result ; + . + +<#literal_with_escaped_LINE_FEED> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_escaped_LINE_FEED" ; + rdfs:comment "literal with escaped LINE FEED" ; + mf:action ; + mf:result ; + . + +<#literal_with_escaped_CARRIAGE_RETURN> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_escaped_CARRIAGE_RETURN" ; + rdfs:comment "literal with escaped CARRIAGE RETURN" ; + mf:action ; + mf:result ; + . + +<#literal_with_escaped_FORM_FEED> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_escaped_FORM_FEED" ; + rdfs:comment "literal with escaped FORM FEED" ; + mf:action ; + mf:result ; + . + +<#literal_with_numeric_escape4> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_numeric_escape4" ; + rdfs:comment "literal with numeric escape4 \\u" ; + mf:action ; + mf:result ; + . + +<#literal_with_numeric_escape8> rdf:type rdft:TestTurtleEval ; + mf:name "literal_with_numeric_escape8" ; + rdfs:comment "literal with numeric escape8 \\U" ; + mf:action ; + mf:result ; + . + +<#IRIREF_datatype> rdf:type rdft:TestTurtleEval ; + mf:name "IRIREF_datatype" ; + rdfs:comment "IRIREF datatype \"\"^^" ; + mf:action ; + mf:result ; + . + +<#prefixed_name_datatype> rdf:type rdft:TestTurtleEval ; + mf:name "prefixed_name_datatype" ; + rdfs:comment "prefixed name datatype \"\"^^p:t" ; + mf:action ; + mf:result ; + . + +<#bareword_integer> rdf:type rdft:TestTurtleEval ; + mf:name "bareword_integer" ; + rdfs:comment "bareword integer" ; + mf:action ; + mf:result ; + . + +<#bareword_decimal> rdf:type rdft:TestTurtleEval ; + mf:name "bareword_decimal" ; + rdfs:comment "bareword decimal" ; + mf:action ; + mf:result ; + . + +<#bareword_double> rdf:type rdft:TestTurtleEval ; + mf:name "bareword_double" ; + rdfs:comment "bareword double" ; + mf:action ; + mf:result ; + . + +<#double_lower_case_e> rdf:type rdft:TestTurtleEval ; + mf:name "double_lower_case_e" ; + rdfs:comment "double lower case e" ; + mf:action ; + mf:result ; + . + +<#negative_numeric> rdf:type rdft:TestTurtleEval ; + mf:name "negative_numeric" ; + rdfs:comment "negative numeric" ; + mf:action ; + mf:result ; + . + +<#positive_numeric> rdf:type rdft:TestTurtleEval ; + mf:name "positive_numeric" ; + rdfs:comment "positive numeric" ; + mf:action ; + mf:result ; + . + +<#numeric_with_leading_0> rdf:type rdft:TestTurtleEval ; + mf:name "numeric_with_leading_0" ; + rdfs:comment "numeric with leading 0" ; + mf:action ; + mf:result ; + . + +<#literal_true> rdf:type rdft:TestTurtleEval ; + mf:name "literal_true" ; + rdfs:comment "literal true" ; + mf:action ; + mf:result ; + . + +<#literal_false> rdf:type rdft:TestTurtleEval ; + mf:name "literal_false" ; + rdfs:comment "literal false" ; + mf:action ; + mf:result ; + . + +<#langtagged_non_LONG> rdf:type rdft:TestTurtleEval ; + mf:name "langtagged_non_LONG" ; + rdfs:comment "langtagged non-LONG \"x\"@en" ; + mf:action ; + mf:result ; + . + +<#langtagged_LONG> rdf:type rdft:TestTurtleEval ; + mf:name "langtagged_LONG" ; + rdfs:comment "langtagged LONG \"\"\"x\"\"\"@en" ; + mf:action ; + mf:result ; + . + +<#lantag_with_subtag> rdf:type rdft:TestTurtleEval ; + mf:name "lantag_with_subtag" ; + rdfs:comment "lantag with subtag \"x\"@en-us" ; + mf:action ; + mf:result ; + . + +<#objectList_with_two_objects> rdf:type rdft:TestTurtleEval ; + mf:name "objectList_with_two_objects" ; + rdfs:comment "objectList with two objects … ," ; + mf:action ; + mf:result ; + . + +<#predicateObjectList_with_two_objectLists> rdf:type rdft:TestTurtleEval ; + mf:name "predicateObjectList_with_two_objectLists" ; + rdfs:comment "predicateObjectList with two objectLists … ," ; + mf:action ; + mf:result ; + . + +<#repeated_semis_at_end> rdf:type rdft:TestTurtleEval ; + mf:name "repeated_semis_at_end" ; + rdfs:comment "repeated semis at end

;; ." ; + mf:action ; + mf:result ; + . + +<#repeated_semis_not_at_end> rdf:type rdft:TestTurtleEval ; + mf:name "repeated_semis_not_at_end" ; + rdfs:comment "repeated semis not at end

;;." ; + mf:action ; + mf:result ; + . + +# original tests-ttl +<#turtle-syntax-file-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-file-01" ; + rdfs:comment "Empty file" ; + mf:action ; + . + +<#turtle-syntax-file-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-file-02" ; + rdfs:comment "Only comment" ; + mf:action ; + . + +<#turtle-syntax-file-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-file-03" ; + rdfs:comment "One comment, one empty line" ; + mf:action ; + . + +<#turtle-syntax-uri-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-uri-01" ; + rdfs:comment "Only IRIs" ; + mf:action ; + . + +<#turtle-syntax-uri-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-uri-02" ; + rdfs:comment "IRIs with Unicode escape" ; + mf:action ; + . + +<#turtle-syntax-uri-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-uri-03" ; + rdfs:comment "IRIs with long Unicode escape" ; + mf:action ; + . + +<#turtle-syntax-uri-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-uri-04" ; + rdfs:comment "Legal IRIs" ; + mf:action ; + . + +<#turtle-syntax-base-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-base-01" ; + rdfs:comment "@base" ; + mf:action ; + . + +<#turtle-syntax-base-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-base-02" ; + rdfs:comment "BASE" ; + mf:action ; + . + +<#turtle-syntax-base-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-base-03" ; + rdfs:comment "@base with relative IRIs" ; + mf:action ; + . + +<#turtle-syntax-base-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-base-04" ; + rdfs:comment "base with relative IRIs" ; + mf:action ; + . + +<#turtle-syntax-prefix-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-01" ; + rdfs:comment "@prefix" ; + mf:action ; + . + +<#turtle-syntax-prefix-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-02" ; + rdfs:comment "PreFIX" ; + mf:action ; + . + +<#turtle-syntax-prefix-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-03" ; + rdfs:comment "Empty PREFIX" ; + mf:action ; + . + +<#turtle-syntax-prefix-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-04" ; + rdfs:comment "Empty @prefix with % escape" ; + mf:action ; + . + +<#turtle-syntax-prefix-05> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-05" ; + rdfs:comment "@prefix with no suffix" ; + mf:action ; + . + +<#turtle-syntax-prefix-06> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-06" ; + rdfs:comment "colon is a legal pname character" ; + mf:action ; + . + +<#turtle-syntax-prefix-07> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-07" ; + rdfs:comment "dash is a legal pname character" ; + mf:action ; + . + +<#turtle-syntax-prefix-08> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-08" ; + rdfs:comment "underscore is a legal pname character" ; + mf:action ; + . + +<#turtle-syntax-prefix-09> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-prefix-09" ; + rdfs:comment "percents in pnames" ; + mf:action ; + . + +<#turtle-syntax-string-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-01" ; + rdfs:comment "string literal" ; + mf:action ; + . + +<#turtle-syntax-string-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-02" ; + rdfs:comment "langString literal" ; + mf:action ; + . + +<#turtle-syntax-string-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-03" ; + rdfs:comment "langString literal with region" ; + mf:action ; + . + +<#turtle-syntax-string-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-04" ; + rdfs:comment "squote string literal" ; + mf:action ; + . + +<#turtle-syntax-string-05> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-05" ; + rdfs:comment "squote langString literal" ; + mf:action ; + . + +<#turtle-syntax-string-06> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-06" ; + rdfs:comment "squote langString literal with region" ; + mf:action ; + . + +<#turtle-syntax-string-07> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-07" ; + rdfs:comment "long string literal with embedded single- and double-quotes" ; + mf:action ; + . + +<#turtle-syntax-string-08> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-08" ; + rdfs:comment "long string literal with embedded newline" ; + mf:action ; + . + +<#turtle-syntax-string-09> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-09" ; + rdfs:comment "squote long string literal with embedded single- and double-quotes" ; + mf:action ; + . + +<#turtle-syntax-string-10> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-10" ; + rdfs:comment "long langString literal with embedded newline" ; + mf:action ; + . + +<#turtle-syntax-string-11> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-string-11" ; + rdfs:comment "squote long langString literal with embedded newline" ; + mf:action ; + . + +<#turtle-syntax-str-esc-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-str-esc-01" ; + rdfs:comment "string literal with escaped newline" ; + mf:action ; + . + +<#turtle-syntax-str-esc-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-str-esc-02" ; + rdfs:comment "string literal with Unicode escape" ; + mf:action ; + . + +<#turtle-syntax-str-esc-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-str-esc-03" ; + rdfs:comment "string literal with long Unicode escape" ; + mf:action ; + . + +<#turtle-syntax-pname-esc-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-pname-esc-01" ; + rdfs:comment "pname with back-slash escapes" ; + mf:action ; + . + +<#turtle-syntax-pname-esc-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-pname-esc-02" ; + rdfs:comment "pname with back-slash escapes (2)" ; + mf:action ; + . + +<#turtle-syntax-pname-esc-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-pname-esc-03" ; + rdfs:comment "pname with back-slash escapes (3)" ; + mf:action ; + . + +<#turtle-syntax-bnode-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-01" ; + rdfs:comment "bnode subject" ; + mf:action ; + . + +<#turtle-syntax-bnode-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-02" ; + rdfs:comment "bnode object" ; + mf:action ; + . + +<#turtle-syntax-bnode-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-03" ; + rdfs:comment "bnode property list object" ; + mf:action ; + . + +<#turtle-syntax-bnode-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-04" ; + rdfs:comment "bnode property list object (2)" ; + mf:action ; + . + +<#turtle-syntax-bnode-05> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-05" ; + rdfs:comment "bnode property list subject" ; + mf:action ; + . + +<#turtle-syntax-bnode-06> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-06" ; + rdfs:comment "labeled bnode subject" ; + mf:action ; + . + +<#turtle-syntax-bnode-07> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-07" ; + rdfs:comment "labeled bnode subject and object" ; + mf:action ; + . + +<#turtle-syntax-bnode-08> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-08" ; + rdfs:comment "bare bnode property list" ; + mf:action ; + . + +<#turtle-syntax-bnode-09> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-09" ; + rdfs:comment "bnode property list" ; + mf:action ; + . + +<#turtle-syntax-bnode-10> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-bnode-10" ; + rdfs:comment "mixed bnode property list and triple" ; + mf:action ; + . + +<#turtle-syntax-number-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-01" ; + rdfs:comment "integer literal" ; + mf:action ; + . + +<#turtle-syntax-number-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-02" ; + rdfs:comment "negative integer literal" ; + mf:action ; + . + +<#turtle-syntax-number-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-03" ; + rdfs:comment "positive integer literal" ; + mf:action ; + . + +<#turtle-syntax-number-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-04" ; + rdfs:comment "decimal literal" ; + mf:action ; + . + +<#turtle-syntax-number-05> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-05" ; + rdfs:comment "decimal literal (no leading digits)" ; + mf:action ; + . + +<#turtle-syntax-number-06> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-06" ; + rdfs:comment "negative decimal literal" ; + mf:action ; + . + +<#turtle-syntax-number-07> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-07" ; + rdfs:comment "positive decimal literal" ; + mf:action ; + . + +<#turtle-syntax-number-08> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-08" ; + rdfs:comment "integer literal with decimal lexical confusion" ; + mf:action ; + . + +<#turtle-syntax-number-09> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-09" ; + rdfs:comment "double literal" ; + mf:action ; + . + +<#turtle-syntax-number-10> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-10" ; + rdfs:comment "negative double literal" ; + mf:action ; + . + +<#turtle-syntax-number-11> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-number-11" ; + rdfs:comment "double literal no fraction" ; + mf:action ; + . + +<#turtle-syntax-datatypes-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-datatypes-01" ; + rdfs:comment "xsd:byte literal" ; + mf:action ; + . + +<#turtle-syntax-datatypes-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-datatypes-02" ; + rdfs:comment "integer as xsd:string" ; + mf:action ; + . + +<#turtle-syntax-kw-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-kw-01" ; + rdfs:comment "boolean literal (true)" ; + mf:action ; + . + +<#turtle-syntax-kw-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-kw-02" ; + rdfs:comment "boolean literal (false)" ; + mf:action ; + . + +<#turtle-syntax-kw-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-kw-03" ; + rdfs:comment "'a' as keyword" ; + mf:action ; + . + +<#turtle-syntax-struct-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-struct-01" ; + rdfs:comment "object list" ; + mf:action ; + . + +<#turtle-syntax-struct-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-struct-02" ; + rdfs:comment "predicate list with object list" ; + mf:action ; + . + +<#turtle-syntax-struct-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-struct-03" ; + rdfs:comment "predicate list with object list and dangling ';'" ; + mf:action ; + . + +<#turtle-syntax-struct-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-struct-04" ; + rdfs:comment "predicate list with multiple ;;" ; + mf:action ; + . + +<#turtle-syntax-struct-05> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-struct-05" ; + rdfs:comment "predicate list with multiple ;;" ; + mf:action ; + . + +<#turtle-syntax-lists-01> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-lists-01" ; + rdfs:comment "empty list" ; + mf:action ; + . + +<#turtle-syntax-lists-02> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-lists-02" ; + rdfs:comment "mixed list" ; + mf:action ; + . + +<#turtle-syntax-lists-03> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-lists-03" ; + rdfs:comment "isomorphic list as subject and object" ; + mf:action ; + . + +<#turtle-syntax-lists-04> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-lists-04" ; + rdfs:comment "lists of lists" ; + mf:action ; + . + +<#turtle-syntax-lists-05> rdf:type rdft:TestTurtlePositiveSyntax ; + mf:name "turtle-syntax-lists-05" ; + rdfs:comment "mixed lists with embedded lists" ; + mf:action ; + . + +<#turtle-syntax-bad-uri-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-uri-01" ; + rdfs:comment "Bad IRI : space (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-uri-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-uri-02" ; + rdfs:comment "Bad IRI : bad escape (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-uri-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-uri-03" ; + rdfs:comment "Bad IRI : bad long escape (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-uri-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-uri-04" ; + rdfs:comment "Bad IRI : character escapes not allowed (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-uri-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-uri-05" ; + rdfs:comment "Bad IRI : character escapes not allowed (2) (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-prefix-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-prefix-01" ; + rdfs:comment "No prefix (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-prefix-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-prefix-02" ; + rdfs:comment "No prefix (2) (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-prefix-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-prefix-03" ; + rdfs:comment "@prefix without URI (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-prefix-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-prefix-04" ; + rdfs:comment "@prefix without prefix name (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-prefix-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-prefix-05" ; + rdfs:comment "@prefix without ':' (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-base-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-base-01" ; + rdfs:comment "@base without URI (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-base-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-base-02" ; + rdfs:comment "@base in wrong case (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-base-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-base-03" ; + rdfs:comment "BASE without URI (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-01" ; + rdfs:comment "Turtle is not TriG (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-02" ; + rdfs:comment "Turtle is not N3 (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-03" ; + rdfs:comment "Turtle is not NQuads (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-04" ; + rdfs:comment "Turtle does not allow literals-as-subjects (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-05" ; + rdfs:comment "Turtle does not allow literals-as-predicates (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-06> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-06" ; + rdfs:comment "Turtle does not allow bnodes-as-predicates (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-07> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-07" ; + rdfs:comment "Turtle does not allow labeled bnodes-as-predicates (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-kw-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-kw-01" ; + rdfs:comment "'A' is not a keyword (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-kw-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-kw-02" ; + rdfs:comment "'a' cannot be used as subject (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-kw-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-kw-03" ; + rdfs:comment "'a' cannot be used as object (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-kw-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-kw-04" ; + rdfs:comment "'true' cannot be used as subject (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-kw-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-kw-05" ; + rdfs:comment "'true' cannot be used as object (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-01" ; + rdfs:comment "{} fomulae not in Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-02" ; + rdfs:comment "= is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-03" ; + rdfs:comment "N3 paths not in Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-04" ; + rdfs:comment "N3 paths not in Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-05" ; + rdfs:comment "N3 is...of not in Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-06> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-06" ; + rdfs:comment "N3 paths not in Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-07> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-07" ; + rdfs:comment "@keywords is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-08> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-08" ; + rdfs:comment "@keywords is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-09> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-09" ; + rdfs:comment "=> is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-10> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-10" ; + rdfs:comment "<= is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-11> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-11" ; + rdfs:comment "@forSome is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-12> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-12" ; + rdfs:comment "@forAll is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-n3-extras-13> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-n3-extras-13" ; + rdfs:comment "@keywords is not Turtle (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-08> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-08" ; + rdfs:comment "missing '.' (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-09> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-09" ; + rdfs:comment "extra '.' (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-10> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-10" ; + rdfs:comment "extra '.' (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-11> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-11" ; + rdfs:comment "trailing ';' no '.' (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-12> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-12" ; + rdfs:comment "subject, predicate, no object (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-13> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-13" ; + rdfs:comment "subject, predicate, no object (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-14> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-14" ; + rdfs:comment "literal as subject (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-15> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-15" ; + rdfs:comment "literal as predicate (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-16> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-16" ; + rdfs:comment "bnode as predicate (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-struct-17> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-struct-17" ; + rdfs:comment "labeled bnode as predicate (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-lang-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-lang-01" ; + rdfs:comment "langString with bad lang (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-esc-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-esc-01" ; + rdfs:comment "Bad string escape (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-esc-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-esc-02" ; + rdfs:comment "Bad string escape (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-esc-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-esc-03" ; + rdfs:comment "Bad string escape (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-esc-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-esc-04" ; + rdfs:comment "Bad string escape (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-pname-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-pname-01" ; + rdfs:comment "'~' must be escaped in pname (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-pname-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-pname-02" ; + rdfs:comment "Bad %-sequence in pname (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-pname-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-pname-03" ; + rdfs:comment "Bad unicode escape in pname (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-01" ; + rdfs:comment "mismatching string literal open/close (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-02" ; + rdfs:comment "mismatching string literal open/close (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-03" ; + rdfs:comment "mismatching string literal long/short (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-04" ; + rdfs:comment "mismatching long string literal open/close (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-05" ; + rdfs:comment "Long literal with missing end (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-06> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-06" ; + rdfs:comment "Long literal with extra quote (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-string-07> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-string-07" ; + rdfs:comment "Long literal with extra squote (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-num-01> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-num-01" ; + rdfs:comment "Bad number format (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-num-02> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-num-02" ; + rdfs:comment "Bad number format (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-num-03> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-num-03" ; + rdfs:comment "Bad number format (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-num-04> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-num-04" ; + rdfs:comment "Bad number format (negative test)" ; + mf:action ; + . + +<#turtle-syntax-bad-num-05> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-num-05" ; + rdfs:comment "Bad number format (negative test)" ; + mf:action ; + . + +<#turtle-eval-struct-01> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-eval-struct-01" ; + rdfs:comment "triple with IRIs" ; + mf:action ; + mf:result ; + . + +<#turtle-eval-struct-02> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-eval-struct-02" ; + rdfs:comment "triple with IRIs and embedded whitespace" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-01> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-01" ; + rdfs:comment "Blank subject" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-02> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-02" ; + rdfs:comment "@prefix and qnames" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-03> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-03" ; + rdfs:comment ", operator" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-04> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-04" ; + rdfs:comment "; operator" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-05> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-05" ; + rdfs:comment "empty [] as subject and object" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-06> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-06" ; + rdfs:comment "non-empty [] as subject and object" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-07> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-07" ; + rdfs:comment "'a' as predicate" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-08> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-08" ; + rdfs:comment "simple collection" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-09> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-09" ; + rdfs:comment "empty collection" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-10> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-10" ; + rdfs:comment "integer datatyped literal" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-11> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-11" ; + rdfs:comment "decimal integer canonicalization" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-12> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-12" ; + rdfs:comment "- and _ in names and qnames" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-13> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-13" ; + rdfs:comment "tests for rdf:_ and other qnames starting with _" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-14> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-14" ; + rdfs:comment "bare : allowed" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-15> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-15" ; + rdfs:comment "simple long literal" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-16> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-16" ; + rdfs:comment "long literals with escapes" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-17> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-17" ; + rdfs:comment "floating point number" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-18> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-18" ; + rdfs:comment "empty literals, normal and long variant" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-19> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-19" ; + rdfs:comment "positive integer, decimal and doubles" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-20> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-20" ; + rdfs:comment "negative integer, decimal and doubles" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-21> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-21" ; + rdfs:comment "long literal ending in double quote" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-22> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-22" ; + rdfs:comment "boolean literals" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-23> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-23" ; + rdfs:comment "comments" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-24> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-24" ; + rdfs:comment "no final mewline" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-25> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-25" ; + rdfs:comment "repeating a @prefix changes pname definition" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-26> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-26" ; + rdfs:comment "Variations on decimal canonicalization" ; + mf:action ; + mf:result ; + . + +<#turtle-subm-27> rdf:type rdft:TestTurtleEval ; + mf:name "turtle-subm-27" ; + rdfs:comment "Repeating @base changes base for relative IRI lookup" ; + mf:action ; + mf:result ; + . + +<#turtle-eval-bad-01> rdf:type rdft:TestTurtleNegativeEval ; + mf:name "turtle-eval-bad-01" ; + rdfs:comment "Bad IRI : good escape, bad charcater (negative evaluation test)" ; + mf:action ; + . + +<#turtle-eval-bad-02> rdf:type rdft:TestTurtleNegativeEval ; + mf:name "turtle-eval-bad-02" ; + rdfs:comment "Bad IRI : hex 3C is < (negative evaluation test)" ; + mf:action ; + . + +<#turtle-eval-bad-03> rdf:type rdft:TestTurtleNegativeEval ; + mf:name "turtle-eval-bad-03" ; + rdfs:comment "Bad IRI : hex 3E is (negative evaluation test)" ; + mf:action ; + . + +<#turtle-eval-bad-04> rdf:type rdft:TestTurtleNegativeEval ; + mf:name "turtle-eval-bad-04" ; + rdfs:comment "Bad IRI : {abc} (negative evaluation test)" ; + mf:action ; + . + +# tests from Dave Beckett +# http://www.w3.org/2011/rdf-wg/wiki/Turtle_Candidate_Recommendation_Comments#c28 +<#LITERAL_LONG2_with_REVERSE_SOLIDUS> rdf:type rdft:TestTurtleEval ; + mf:name "LITERAL_LONG2_with_REVERSE_SOLIDUS" ; + rdfs:comment "REVERSE SOLIDUS at end of LITERAL_LONG2" ; + mf:action ; + mf:result ; + . + +<#turtle-syntax-bad-LITERAL2_with_langtag_and_datatype> rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "turtle-syntax-bad-num-05" ; + rdfs:comment "Bad number format (negative test)" ; + mf:action ; + . + +<#two_LITERAL_LONG2s> rdf:type rdft:TestTurtleEval ; + mf:name "two_LITERAL_LONG2s" ; + rdfs:comment "two LITERAL_LONG2s testing quote delimiter overrun" ; + mf:action ; + mf:result ; + . + +<#langtagged_LONG_with_subtag> rdf:type rdft:TestTurtleEval ; + mf:name "langtagged_LONG_with_subtag" ; + rdfs:comment "langtagged LONG with subtag \"\"\"Cheers\"\"\"@en-UK" ; + mf:action ; + mf:result ; + . + +# tests from David Robillard +# http://www.w3.org/2011/rdf-wg/wiki/Turtle_Candidate_Recommendation_Comments#c21 +<#turtle-syntax-bad-blank-label-dot-end> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Blank node label must not end in dot" ; + mf:name "turtle-syntax-bad-blank-label-dot-end" ; + mf:action . + +<#turtle-syntax-bad-number-dot-in-anon> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Dot delimeter may not appear in anonymous nodes" ; + mf:name "turtle-syntax-bad-number-dot-in-anon" ; + mf:action . + +<#turtle-syntax-bad-ln-dash-start> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Local name must not begin with dash" ; + mf:name "turtle-syntax-bad-ln-dash-start" ; + mf:action . + +<#turtle-syntax-bad-ln-escape> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Bad hex escape in local name" ; + mf:name "turtle-syntax-bad-ln-escape" ; + mf:action . + +<#turtle-syntax-bad-ln-escape-start> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Bad hex escape at start of local name" ; + mf:name "turtle-syntax-bad-ln-escape-start" ; + mf:action . + +<#turtle-syntax-bad-ns-dot-end> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Prefix must not end in dot" ; + mf:name "turtle-syntax-bad-ns-dot-end" ; + mf:action . + +<#turtle-syntax-bad-ns-dot-start> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Prefix must not start with dot" ; + mf:name "turtle-syntax-bad-ns-dot-start" ; + mf:action . + +<#turtle-syntax-bad-missing-ns-dot-end> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Prefix must not end in dot (error in triple, not prefix directive like turtle-syntax-bad-ns-dot-end)" ; + mf:name "turtle-syntax-bad-missing-ns-dot-end" ; + mf:action . + +<#turtle-syntax-bad-missing-ns-dot-start> + rdf:type rdft:TestTurtleNegativeSyntax ; + rdfs:comment "Prefix must not start with dot (error in triple, not prefix directive like turtle-syntax-bad-ns-dot-end)" ; + mf:name "turtle-syntax-bad-missing-ns-dot-start" ; + mf:action . + +<#turtle-syntax-ln-dots> + rdf:type rdft:TestTurtlePositiveSyntax ; + rdfs:comment "Dots in pname local names" ; + mf:name "turtle-syntax-ln-dots" ; + mf:action . + +<#turtle-syntax-ln-colons> + rdf:type rdft:TestTurtlePositiveSyntax ; + rdfs:comment "Colons in pname local names" ; + mf:name "turtle-syntax-ln-colons" ; + mf:action . + +<#turtle-syntax-ns-dots> + rdf:type rdft:TestTurtlePositiveSyntax ; + rdfs:comment "Dots in namespace names" ; + mf:name "turtle-syntax-ns-dots" ; + mf:action . + +<#turtle-syntax-blank-label> + rdf:type rdft:TestTurtlePositiveSyntax ; + rdfs:comment "Characters allowed in blank node labels" ; + mf:name "turtle-syntax-blank-label" ; + mf:action . diff --git a/arc2-2.2.4/tests/functional/ARC2_ReaderTest.php b/arc2-2.2.4/tests/functional/ARC2_ReaderTest.php new file mode 100755 index 0000000..babe542 --- /dev/null +++ b/arc2-2.2.4/tests/functional/ARC2_ReaderTest.php @@ -0,0 +1,12 @@ +arc2 = new ARC2_Class(array(), new stdClass); + } + + public function testCamelCase() { + $this->assertSame("Fish", $this->arc2->camelCase("fish")); + $this->assertSame("fish", $this->arc2->camelCase("fish", true)); + $this->assertSame("fish", $this->arc2->camelCase("fish", true, true)); + + $this->assertSame("FishHeads", $this->arc2->camelCase("fish_heads")); + $this->assertSame("fishHeads", $this->arc2->camelCase("fish_heads", true)); + $this->assertSame("fishHeads", $this->arc2->camelCase("fish_heads", true, true)); + + $this->assertSame("ALLCAPITALS", $this->arc2->camelCase("ALL_CAPITALS")); + } + + public function testDeCamelCase() { + $this->assertSame("fish", $this->arc2->deCamelCase("fish")); + $this->assertSame("Fish", $this->arc2->deCamelCase("fish", true)); + + $this->assertSame("fish heads", $this->arc2->deCamelCase("fish_heads")); + $this->assertSame("Fish heads", $this->arc2->deCamelCase("fish_heads", true)); + + $this->assertSame("ALL CAPITALS", $this->arc2->deCamelCase("ALL_CAPITALS")); + } + + + public function testV() { + $this->assertSame(false, $this->arc2->v(null)); + $this->assertSame(false, $this->arc2->v("cats", false, array())); + $this->assertSame(true, $this->arc2->v("cats", false, array("cats" => true))); + + $o = new stdclass; + $o->cats = true; + $this->assertSame(true, $this->arc2->v("cats", false, $o)); + } + + public function testV1() { + $this->assertSame(false, $this->arc2->v1(null)); + $this->assertSame(false, $this->arc2->v1("cats", false, array())); + $this->assertSame(true, $this->arc2->v1("cats", false, array("cats" => true))); + $this->assertSame("blackjack", $this->arc2->v1("cats", "blackjack", array("cats" => null))); + + $o = new stdclass; + $o->cats = true; + $this->assertSame(true, $this->arc2->v1("cats", false, $o)); + + $o = new stdclass; + $o->cats = 0; + $this->assertSame("blackjack", $this->arc2->v1("cats", "blackjack", $o)); + } + + public function testExtractTermLabel() { + $this->assertSame("bar", $this->arc2->extractTermLabel('http://example.com/foo#bar')); + $this->assertSame("bar cats", $this->arc2->extractTermLabel('http://example.com/foo#bar?cats')); + $this->assertSame("bar", $this->arc2->extractTermLabel('#bar')); + $this->assertSame("bar", $this->arc2->extractTermLabel('http://example.com/bar')); + $this->assertSame("bar", $this->arc2->extractTermLabel('http://example.com/bar/')); + } + +} diff --git a/arc2-2.2.4/tests/unit/ARC2_GraphTest.php b/arc2-2.2.4/tests/unit/ARC2_GraphTest.php new file mode 100755 index 0000000..671885b --- /dev/null +++ b/arc2-2.2.4/tests/unit/ARC2_GraphTest.php @@ -0,0 +1,208 @@ +obj = ARC2::getGraph(); + $this->res1 = array( + 'http://example.com/s1' => array( + 'http://example.com/p1' => array( + array('value' => 'o1', 'type' => 'literal'), + array('value' => 'http://example.com/o1', 'type' => 'uri'), + ), + ), + ); + $this->res2 = array( + 'http://example.com/s2' => array( + 'http://example.com/p2' => array( + array('value' => 'o2', 'type' => 'literal'), + array('value' => 'http://example.com/o2', 'type' => 'uri'), + ), + ), + ); + $this->res3 = array( + 'http://example.com/s1' => array( + 'http://example.com/p3' => array( + array('value' => 'o3', 'type' => 'literal'), + ), + ), + ); + } + + public function testSetIndex() { + $actual = $this->obj->setIndex($this->res1); + $this->assertSame($this->obj, $actual); + + $actual = $this->obj->getIndex(); + $this->assertEquals($this->res1, $actual); + } + + public function testGetIndex() { + $actual = $this->obj->getIndex(); + $this->assertTrue(is_array($actual), 'should return array'); + } + + public function testAddIndex() { + $actual = $this->obj->addIndex($this->res1); + $this->assertSame($this->obj, $actual); + + $actual = $this->obj->getIndex(); + $this->assertEquals($this->res1, $actual); + + $this->obj->addIndex($this->res1); + $actual = $this->obj->getIndex(); + $this->assertEquals($this->res1, $actual); + + $this->obj->addIndex($this->res2); + $actual = $this->obj->getIndex(); + $this->assertEquals(array_merge($this->res1, $this->res2), $actual); + + $this->obj->addIndex($this->res3); + $actual = $this->obj->getIndex(); + $this->assertEquals(2, count(array_keys($actual['http://example.com/s1']))); + $this->assertEquals(1, count(array_keys($actual['http://example.com/s2']))); + } + + public function testAddGraph() { + $this->obj->addIndex($this->res1); + $g2 = ARC2::getGraph()->addIndex($this->res2); + + $actual = $this->obj->addGraph($g2); + $this->assertSame($this->obj, $actual); + + $actual = $this->obj->getIndex(); + $this->assertEquals(array_merge($this->res1, $this->res2), $actual); + } + + public function testAddGraphWithNamespaces() { + $g2 = ARC2::getGraph()->setPrefix('ex', 'http://example.com/'); + + $actual = $this->obj->addGraph($g2); + $this->assertArrayHasKey('ex', $actual->ns); + } + + public function testAddRdf() { + $rdf = $this->obj->toTurtle($this->res1); + $this->obj->addRdf($rdf, 'turtle'); + $actual = $this->obj->getIndex(); + $this->assertEquals($this->res1, $actual); + + $rdf = json_encode($this->res2); + $this->obj->addRdf($rdf, 'json'); + $actual = $this->obj->getIndex(); + $this->assertEquals(array_merge($this->res1, $this->res2), $actual); + } + + public function testHasSubject() { + $actual = $this->obj->setIndex($this->res1); + $this->assertTrue($actual->hasSubject('http://example.com/s1')); + $this->assertFalse($actual->hasSubject('http://example.com/s2')); + } + + public function testHasTriple() { + $actual = $this->obj->setIndex($this->res1); + $this->assertTrue($actual->hasTriple('http://example.com/s1', 'http://example.com/p1', 'o1')); + $this->assertFalse($actual->hasTriple('http://example.com/s1', 'http://example.com/p1', 'o2')); + $this->assertTrue($actual->hasTriple('http://example.com/s1', 'http://example.com/p1', array('value' => 'o1', 'type' => 'literal'))); + $this->assertFalse($actual->hasTriple('http://example.com/s1', 'http://example.com/p1', array('value' => 'o1', 'type' => 'uri'))); + } + + public function testHasLiteralTriple() { + $actual = $this->obj->setIndex($this->res2); + $this->assertTrue($actual->hasLiteralTriple('http://example.com/s2', 'http://example.com/p2', 'o2')); + $this->assertFalse($actual->hasLiteralTriple('http://example.com/s1', 'http://example.com/p1', 'o2')); + } + + public function testHasLinkTriple() { + $actual = $this->obj->setIndex($this->res2); + $this->assertTrue($actual->hasLinkTriple('http://example.com/s2', 'http://example.com/p2', 'http://example.com/o2')); + $this->assertFalse($actual->hasLinkTriple('http://example.com/s2', 'http://example.com/p2', 'o2')); + } + + public function testAddTriple() { + $actual = $this->obj->addTriple('_:s1', '_:p1', 'o1'); + $this->assertTrue($actual->hasLiteralTriple('_:s1', '_:p1', 'o1')); + + $actual = $this->obj->addTriple('_:s1', '_:p1', 'o1', 'bnode'); + $this->assertTrue($actual->hasLinkTriple('_:s1', '_:p1', 'o1')); + } + + public function testGetSubjects() { + $g = $this->obj->setIndex($this->res1); + + $actual = $g->getSubjects(); + $this->assertEquals(array('http://example.com/s1'), $actual); + + $actual = $g->getSubjects('p'); + $this->assertEquals(array(), $actual); + + $actual = $g->getSubjects('http://example.com/p1'); + $this->assertEquals(array('http://example.com/s1'), $actual); + + $actual = $g->getSubjects(null, 'o'); + $this->assertEquals(array(), $actual); + + $actual = $g->getSubjects(null, 'o1'); + $this->assertEquals(array('http://example.com/s1'), $actual); + + $actual = $g->getSubjects(null, array('value' => 'http://example.com/o1', 'type' => 'uri')); + $this->assertEquals(array('http://example.com/s1'), $actual); + + $actual = $g->getSubjects('http://example.com/p1', 'o'); + $this->assertEquals(array(), $actual); + + $actual = $g->getSubjects('http://example.com/p1', 'o1'); + $this->assertEquals(array('http://example.com/s1'), $actual); + + } + + public function testGetPredicates() { + $g = $this->obj->setIndex($this->res1)->addIndex($this->res2); + + $actual = $g->getPredicates(); + $this->assertEquals(array('http://example.com/p1', 'http://example.com/p2'), $actual); + + $actual = $g->getPredicates('http://example.com/s2'); + $this->assertEquals(array('http://example.com/p2'), $actual); + } + + public function testGetObjects() { + $actual = $this->obj->setIndex($this->res1)->getObjects('http://example.com/s1', 'http://example.com/p1', true); + $this->assertEmpty(array_diff(array('http://example.com/o1', 'o1'), $actual)); + $this->assertEmpty(array_diff($actual, array('http://example.com/o1', 'o1'))); + + $actual = $this->obj->setIndex($this->res3)->getObjects('http://example.com/s1', 'http://example.com/p3'); + $this->assertEquals(array(array('value' => 'o3', 'type' => 'literal')), $actual); + } + + public function testGetObject() { + $actual = $this->obj->setIndex($this->res1)->getObject('http://example.com/s1', 'http://example.com/p1', true); + $this->assertEquals('o1', $actual); + + $actual = $this->obj->setIndex($this->res3)->getObject('http://example.com/s1', 'http://example.com/p3'); + $this->assertEquals(array('value' => 'o3', 'type' => 'literal'), $actual); + } + + public function testGetNtriples() { + $actual = $this->obj->setIndex($this->res3)->getNTriples(); + $this->assertContains(' "o3"', $actual); + } + + public function testGetTurtle() { + $actual = $this->obj->setIndex($this->res3)->setPrefix('ex', 'http://example.com/')->getTurtle(); + $this->assertContains(' ex:p3 "o3"', $actual); + } + + public function testGetRDFXML() { + $actual = $this->obj->setIndex($this->res3)->getRDFXML(); + $this->assertContains('', $actual); + } + + public function testGetJSON() { + $actual = $this->obj->setIndex($this->res3)->getJSON(); + $this->assertContains('{"http:\/\/example.com\/s1":', $actual); + } + +} diff --git a/arc2-2.2.4/tests/unit/ARC2_Test.php b/arc2-2.2.4/tests/unit/ARC2_Test.php new file mode 100755 index 0000000..9573492 --- /dev/null +++ b/arc2-2.2.4/tests/unit/ARC2_Test.php @@ -0,0 +1,124 @@ +assertRegExp('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $actual, "should start with date"); + } + + public function testGetIncPath() { + $actual = ARC2::getIncPath('RDFParser'); + $this->assertStringEndsWith('parsers/', $actual, 'should create correct path'); + $this->assertTrue(is_dir($actual), 'should create correct pointer'); + } + + public function testGetScriptURI() { + $tmp = $_SERVER; + unset($_SERVER); + $actual = ARC2::getScriptURI(); + $this->assertEquals('http://localhost/unknown_path', $actual); + $_SERVER = $tmp; + + $_SERVER = array( + 'SERVER_PROTOCOL' => 'http', + 'SERVER_PORT' => 443, + 'HTTP_HOST' => 'example.com', + 'SCRIPT_NAME' => '/foo' + ); + $actual = ARC2::getScriptURI(); + $this->assertEquals('https://example.com/foo', $actual); + $_SERVER = $tmp; + + unset($_SERVER['HTTP_HOST']); + unset($_SERVER['SERVER_NAME']); + $_SERVER['SCRIPT_FILENAME'] = __FILE__; + $actual = ARC2::getScriptURI(); + $this->assertEquals('file://' . __FILE__, $actual); + $_SERVER = $tmp; + } + + public function testGetRequestURI() { + $tmp = $_SERVER; + unset($_SERVER); + $actual = ARC2::getRequestURI(); + $this->assertEquals(ARC2::getScriptURI(), $actual); + $_SERVER = $tmp; + + $_SERVER = array( + 'SERVER_PROTOCOL' => 'http', + 'SERVER_PORT' => 1234, + 'HTTP_HOST' => 'example.com', + 'REQUEST_URI' => '/foo' + ); + $actual = ARC2::getRequestURI(); + $this->assertEquals('http://example.com:1234/foo', $actual); + $_SERVER = $tmp; + } + + public function testInc() { + $actual = ARC2::inc('Class'); + $this->assertNotEquals(0, $actual); + + $actual = ARC2::inc('RDFParser'); + $this->assertNotEquals(0, $actual); + + $actual = ARC2::inc('ARC2_RDFParser'); + $this->assertNotEquals(0, $actual); + + $actual = ARC2::inc('Foo'); + $this->assertEquals(0, $actual); + + $actual = ARC2::inc('Vendor_Foo'); + $this->assertEquals(0, $actual); + } + + public function testMtime() { + $actual = ARC2::mtime(); + $this->assertTrue(is_float($actual)); + } + + public function testX() { + $actual = ARC2::x('foo', ' foobar'); + $this->assertEquals('bar', $actual[1]); + } + + public function testToUTF8() { + $actual = ARC2::toUTF8('foo'); + $this->assertEquals('foo', $actual); + + $actual = ARC2::toUTF8(utf8_encode('Iñtërnâtiônàlizætiøn')); + $this->assertEquals('Iñtërnâtiônàlizætiøn', $actual); + } + + public function testSplitURI() { + $actual = ARC2::splitURI('http://www.w3.org/XML/1998/namespacefoo'); + $this->assertEquals(array('http://www.w3.org/XML/1998/namespace', 'foo'), $actual); + + $actual = ARC2::splitURI('http://www.w3.org/2005/Atomfoo'); + $this->assertEquals(array('http://www.w3.org/2005/Atom', 'foo'), $actual); + + $actual = ARC2::splitURI('http://www.w3.org/2005/Atom#foo'); + $this->assertEquals(array('http://www.w3.org/2005/Atom#', 'foo'), $actual); + + $actual = ARC2::splitURI('http://www.w3.org/1999/xhtmlfoo'); + $this->assertEquals(array('http://www.w3.org/1999/xhtml', 'foo'), $actual); + + $actual = ARC2::splitURI('http://www.w3.org/1999/02/22-rdf-syntax-ns#foo'); + $this->assertEquals(array('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'foo'), $actual); + + $actual = ARC2::splitURI('http://example.com/foo'); + $this->assertEquals(array('http://example.com/', 'foo'), $actual); + + $actual = ARC2::splitURI('http://example.com/foo/bar'); + $this->assertEquals(array('http://example.com/foo/', 'bar'), $actual); + + $actual = ARC2::splitURI('http://example.com/foo#bar'); + $this->assertEquals(array('http://example.com/foo#', 'bar'), $actual); + + } + + +} diff --git a/arc2-2.2.4/tests/unit/ARC2_getFormatTest.php b/arc2-2.2.4/tests/unit/ARC2_getFormatTest.php new file mode 100755 index 0000000..cc180bc --- /dev/null +++ b/arc2-2.2.4/tests/unit/ARC2_getFormatTest.php @@ -0,0 +1,73 @@ +assertEquals('atom', $actual); + + $actual = ARC2::getFormat($data); + $this->assertEquals('atom', $actual); + } + + public function testGetFormatWithRdfXml() { + $data = file_get_contents('../data/rdfxml/planetrdf-bloggers.rdf'); + + $actual = ARC2::getFormat($data, 'application/rdf+xml'); + $this->assertEquals('rdfxml', $actual); + + $actual = ARC2::getFormat($data); + $this->assertEquals('rdfxml', $actual); + } + + public function testGetFormatWithTurtle() { + $data = file_get_contents('../data/turtle/manifest.ttl'); + + $actual = ARC2::getFormat($data, 'text/turtle'); + $this->assertEquals('turtle', $actual); + + $actual = ARC2::getFormat($data); + $this->assertEquals('turtle', $actual); + } + + public function testGetFormatWithJson() { + $data = file_get_contents('../data/json/sparql-select-result.json'); + + $actual = ARC2::getFormat($data, 'application/json'); + $this->assertEquals('json', $actual); + + $actual = ARC2::getFormat($data); + $this->assertEquals('json', $actual); + + $data = file_get_contents('../data/json/crunchbase-facebook.js'); + + $actual = ARC2::getFormat($data); + $this->assertEquals('cbjson', $actual); + + } + + public function testGetFormatWithN3() { + $data = file_get_contents('../data/nt/test.nt'); + + $actual = ARC2::getFormat($data, 'application/rdf+n3'); + $this->assertEquals('n3', $actual); + + $actual = ARC2::getFormat($data, '', 'n3'); + $this->assertEquals('n3', $actual); + } + + public function testGetFormatWithNTriples() { + $data = file_get_contents('../data/nt/test.nt'); + + $actual = ARC2::getFormat($data); + $this->assertEquals('ntriples', $actual); + + $actual = ARC2::getFormat($data, '', 'nt'); + $this->assertEquals('ntriples', $actual); + } + +} diff --git a/arc2-2.2.4/tests/unit/ARC2_getPreferredFormatTest.php b/arc2-2.2.4/tests/unit/ARC2_getPreferredFormatTest.php new file mode 100755 index 0000000..6adc57e --- /dev/null +++ b/arc2-2.2.4/tests/unit/ARC2_getPreferredFormatTest.php @@ -0,0 +1,24 @@ +assertEquals('XML', $actual); + + $actual = ARC2::getPreferredFormat('foo'); + $this->assertEquals(null, $actual); + + $_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; + $actual = ARC2::getPreferredFormat(); + $this->assertEquals('HTML', $actual); + + $_SERVER['HTTP_ACCEPT'] = 'application/rdf+xml,text/html;q=0.9,*/*;q=0.8'; + $actual = ARC2::getPreferredFormat(); + $this->assertEquals('RDFXML', $actual); + } + +} diff --git a/arc2-2.2.4/tests/unit/phpunit.xml b/arc2-2.2.4/tests/unit/phpunit.xml new file mode 100755 index 0000000..d00dbcc --- /dev/null +++ b/arc2-2.2.4/tests/unit/phpunit.xml @@ -0,0 +1,16 @@ + + + + + + + + + ../.. + + ../../tests + + + + + diff --git a/controllers/default.inc b/controllers/default.inc new file mode 100644 index 0000000..3923c99 --- /dev/null +++ b/controllers/default.inc @@ -0,0 +1,116 @@ + 'odrl', + 'http://creativecommons.org/ns#' => 'cc', + 'http://purl.oclc.org/NET/ldr/ns#'=>'ldr-oclc', + 'http://purl.org/NET/ldr/ns#' => 'ldr', + 'http://www.editeur.org/onix-pl/'=>'onix', + + ); + protected $_model = NULL; + public function __construct($args = array()){ + parent::__construct($args); + session_start(); + + // XXX Not implemented yet + $_SESSION['userid'] = 0; + + // Setup model + $this->_model = array( + 'title' => '', + 'nav' => array( + + ), + 'page' => 'index', + 'data' => array() + ); + } + + protected function _userid(){ + return $_SESSION['userid']; + } + + public function model(){ + return $this->_model; + } + + protected function _forbidden($reason = ''){ + header('HTTP/1.0 403 Forbidden'); + $m = $this->model(); + $m['title'] = ''; + $m['nav'] = array(); + $m['actions'] = array(); + $m['data']['user'] = $m['user']; + $m['data']['reason'] = $reason; + $m['page'] = 'sorry'; + $v = new MVC_Viewer($m); + $v->render('layout'); + die; + } + + public function prefix($ns){ + if(isset($this->_prefix[$ns])){ + return $this->_prefix[$ns]; + } + return false; + } + + public function prefixed($uri){ + $ns = $this->guessNamespace($uri); + if($prefix = $this->prefix($ns)){ + return $prefix . ':' . $this->guessName($uri); + } + return $uri; + } + + public function guessName ($uri) { + return substr($uri,$this->getNamespaceEnd($uri)); + } + + public function guessNamespace ($uri) { + $l = $this->getNamespaceEnd($uri); + return $l > 1 ? substr($uri ,0, $l) : ""; + } + + public function getNamespaceEnd ($uri) { + $l = strlen($uri)-1; + do { + $c = substr($uri, $l, 1); + if($c == '#' || $c == ':' || $c == '/') + break; + $l--; + } while ($l >= 0); + $l++; + return $l; + } + + public function indexAction(){ + $m = $this->model(); + $v = new MVC_Viewer($m); + $v->render('layout'); + } + + protected function _message($type, $text){ + if(!isset($_SESSION['messages']) || !is_array($_SESSION['messages'])){ + $_SESSION['messages'] = array(); + } + if(!isset($_SESSION['messages'][$type]) || !is_array($_SESSION['messages'][$type])){ + $_SESSION['messages'][$type] = array(); + } + array_push($_SESSION['messages'][$type], $text); + } + + protected function _info($t){ + $this->_message('info', $t); + } + protected function _warning($t){ + $this->_message('warning', $t); + } + protected function _danger($t){ + $this->_message('danger', $t); + } + protected function _success($t){ + $this->_message('success', $t); + } +} \ No newline at end of file diff --git a/controllers/ontology.inc b/controllers/ontology.inc new file mode 100644 index 0000000..eb4fa28 --- /dev/null +++ b/controllers/ontology.inc @@ -0,0 +1,23 @@ + 'http://xmlns.com/foaf/0.1/', + 'dc' => 'http://purl.org/dc/elements/1.1/', + 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', + 'contento' => 'http://www.example.org/contento/', + 'contento_ns' => 'http://www.example.org/contento/ns/', + 'odrl' => 'http://www.w3.org/ns/odrl/2/', + 'dct' => 'http://purl.org/dc/terms/', + 'cc' => 'http://creativecommons.org/ns#', + 'skos' => 'http://www.w3.org/2004/02/skos/core#', + 'owl' => '' + ); + $ser = ARC2::getTurtleSerializer(array('ns' => $ns)); + header("Content-type: text/plain; charset=utf-8"); + print $ser->getSerializedIndex($d->getTriplesIndex(DataAccess::TAXONOMY)); + } +} \ No newline at end of file diff --git a/controllers/picker.inc b/controllers/picker.inc new file mode 100644 index 0000000..3c4ccc5 --- /dev/null +++ b/controllers/picker.inc @@ -0,0 +1,199 @@ +pickerAction(); + } + + public function rebuildAction(){ + DataAccess::rebuild(); + $this->_success('The knowledge base has been rebuilt.'); + header('Location: ' . route('default', 'index'), 201); + } + + public function pickerAction(){ + $d = DataAccess::instance(); + + // top and bottom + $top = $d->top(); + $bottom = $d->bottom(); + + // initialize yes questions (get concepts from ids) + $yesq = array(); // contains yes concepts + if($this->has('yes')) { + $yes = $this->get('yes'); // contains yes conceptsIds + foreach($yes as $y){ + array_push($yesq, $d->question($y)); + } + }else{ + $yes = array(); + } + + // initialize no questions (get concepts from ids) + $noq = array(); // contains no concepts + if($this->has('no')) { + $no = $this->get('no'); // contains no conceptsId + foreach($no as $y){ + array_push($noq, $d->question($y)); + } + }else{ + $no = array(); + } + + // initialized actions stack (history) + if($this->has('stack')){ + $stack = $this->get('stack'); + }else{ + $stack = array(); + /* + * stack is a list of yes/no actions performed, + * so that we know from which list we have to remove + * the last element when the user performs undo + */ + } + + // perform sat yes action and set current node/concept + if($this->has('sayyes')) { + // add action to stack (history) + array_push($stack,'sayyes'); + // set current question (later we'll branch from here) + $current = $d->question($this->get('sayyes')); + // add current concept to yes list + array_push($yes, $current['concept']); // id + array_push($yesq, $current); // full desc + } else if($this->has('current')) { + // if other action, set current concept + $current = $d->question($this->get('current')); + } else { + // by default + $current = $d->top(); + } + + // perform say no action + if($this->has('sayno')) { + // add to stack + array_push($stack, 'sayno'); + array_push($no, $this->get('sayno')); + array_push($noq, $d->question($this->get('sayno'))); + } + + // perform undo action + if($this->has('undo')){ + /* + * order is important, we modify here variables alrady set + */ + $undo = array_pop($stack); + if($undo == 'sayyes'){ + array_pop($yes); + array_pop($yesq); + if(count($yesq)>0){ + $current = $yesq[count($yesq)-1]; + } else { + $current = $top; + } + }else if($undo == 'sayno'){ + array_pop($no); + array_pop($noq); + } + } + + $q = $this->_prepareQuestions($current, $yes, $no, $top, $bottom); + $lyes = $this->_prepareLicences($yes, $no); + + // attach policies to the licences to display + foreach($lyes as &$l){ + $l['policies'] = array(); + $policies = $d->policies($l['licence']); + foreach($policies as $type => $rows){ + $l['policies'][$type] = array(); + foreach($rows as $row){ + array_push($l['policies'][$type], $this->prefixed($row[$type])); + } + } + } + + $isBottom = ($q[0] == $bottom); + // Prepare model + $m = $this->model(); + $m['data'] = array( + 'yes' => $yesq, + 'no' => $noq, + 'questions' => $q, + 'licences' => $lyes, + 'current' => $current, + 'stack' => $stack, + 'isBottom' => $isBottom + ); + $m['page'] = 'picker'; + $v = new MVC_Html($m); + $v->render('layout'); + } + + private function _prepareQuestions($current, $yes, $no, $top, $bottom){ + $d = DataAccess::instance(); + // Branch + $q = $d->childrenQuestionsOf($current); + //print_r($q); die; + // check if branching to bottom + $isBottom = ($q[0] == $bottom); + // In this case check whether there are unanswered + // questions in one of the immediate parents +// if($isBottom){ +// $q = $d->parentQuestionsOf($current); +// //print_r($q); die; +// // remove all yes from questions (already answered) +// $rq = array(); // indexes of questions to remove +// for($i=0; $ilicences($yes); + + // remove all licences in no questions + $lno = array(); // licences that are instances of no concepts + foreach($no as $n){ + $nos = $d->licencesOfType($n); + $lno = array_merge($lno, $nos); + } + $rix = array(); // indexes of licences to remove + $i=0; + for($i=0; $iget ( 'id' ) . '.css' ); + } + public function d3Action() { + header ( "Content-type: application/javascript; charset=utf8" ); + print file_get_contents ( dirname ( __FILE__ ) . '/../d3/d3.min.js' ); + } + public function jsAction() { + if (! $this->has ( 'name' )) + error_malformed ( 'Missing parameter:' . name ); + $name = $this->get ( 'name' ); + header ( "Content-type: application/javascript; charset=utf8" ); + print file_get_contents ( dirname ( __FILE__ ) . '/../js/' . $name ); + } +} \ No newline at end of file diff --git a/dataaccess.inc b/dataaccess.inc new file mode 100644 index 0000000..1071547 --- /dev/null +++ b/dataaccess.inc @@ -0,0 +1,490 @@ +_ini = $ini; + $this->init ($rebuild); + } + + public function init($rebuild=false) { + $this->_store = ARC2::getStore ( $this->config ( 'arc' ) ); + + $errs = $this->_store->getErrors (); + if (count ( $errs ) > 0) { + throw new DataAccessException ( $errs ); + } + // + $store = $this->_store; + if ($rebuild && $store->isSetUp ()) { + $store->drop (); + } + if (! $store->isSetUp ()) { + try { + $store->setUp (); + $parser = ARC2::getTurtleParser (); + $parser->parse ( dirname ( __FILE__ ) . '/resources/' . $this->_ini ['resources'] ['taxonomy'] ); + if ($parser->getErrors ()) { + throw new DataAccessException ( $parser->getErrors () ); + } + $store->insert ( $parser->getTriples (), self::TAXONOMY ); + + // rewrite triples + $triples = $parser->getTriples (); + $toadd = array (); + for($i = 0, $i_max = count ( $triples ); $i < $i_max; $i ++) { + $triple = $triples [$i]; + if ($triple ['p'] === self::CONTENTO_HAS) { + $o = $triple ['o']; + if($o === '') continue; + $oparts = explode ( ' ', $o ); + $p = 'http://www.w3.org/ns/odrl/2/' . $oparts [0]; +// if(!isset($oparts[1])){ +// print_r($triple); +// print_r($oparts); +// die; +// } + array_push ( $toadd, array ( + 's' => $triple ['s'], + 's_type' => $triple ['s_type'], + 'o' => $oparts [1], + 'o_type' => 'uri', + 'p' => $p + ) ); + + // specify this is a licence from the taxonomy + array_push ( $toadd, array ( + 's' => $triple ['s'], + 's_type' => $triple ['s_type'], + 'o' => self::TAXONOMY, + 'o_type' => 'uri', + 'p' => 'http://rdfs.org/ns/void#inDataset' + ) ); + } + } + // if it is subclass of + if ($triple ['p'] === self::RDFS_SUBCLASS_OF) { + // rewrite with skos narrower + array_push ( $toadd, array ( + 's' => $triple ['s'], + 's_type' => $triple ['s_type'], + 'o' => $triple['o'], + 'o_type' => 'uri', + 'p' => self::SKOS_BROADER + ) ); + + // materialize transitive closure + //$subclasses = $this->_transitiveClosure($triples, $triple['s'], $triple['p']); + + } + $store->insert ( $toadd, self::TAXONOMY ); + + $parser = ARC2::getTurtleParser (); + $parser->parse ( dirname ( __FILE__ ) . '/resources/' . $this->_ini ['resources'] ['rdflicense'] ); + if ($parser->getErrors ()) { + throw new DataAccessException ( $parser->getErrors () ); + } + $store->insert ( $parser->getTriples (), self::RDFLICENSE ); + + if ($store->getErrors ()) { + throw new DataAccessException ( $store->getErrors () ); + } + } catch ( Exception $e ) { + $store->drop (); + throw $e; + } + + + } + + + //$graphs = $this->_store->query ( "select ?l where { ?l }" ); + //$r = $this->_store->query ( $q ); +// $errs = $this->_store->getErrors (); +// if (count ( $errs ) > 0) { +// throw new DataAccessException ( $errs ); +// }else{ +// print_r($r); die; +// } + // $parser = ARC2::getTurtleParser(); + // $parser->parse( dirname(__FILE__) . '/resources/' . $ini['resources']['taxonomy'] ); + // //print dirname(__FILE__) . '/resources/' . $ini['resources.taxonomy'] ; + // if($parser->getErrors()) { + // throw new Exception('Parser error!' . print_r($parser->getErrors(), TRUE)); + // } + // $this->_contento = $parser->getTriples(); + } + + public function store(){ + return $this->_store; + } + + public function contento() { + return $this->_contento; + } + + public function config($section = FALSE) { + if ($section === FALSE) { + return $this->_ini; + } else { + return $this->_ini [$section]; + } + } + + public function top(){ + $q = << + prefix rdf: + PREFIX rdfs: + select ?concept ?label ?question where { + ?concept a . + filter(!bound(?parent)) . + optional { + ?concept rdfs:subClassOf ?parent + } + ?concept rdfs:comment ?question . + ?concept rdfs:label ?label + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows[0]; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + + public function getTriplesIndex($graph){ + $store = $this->_store; + $q = << + prefix contento: + prefix rdfs: + prefix contento_ns: + prefix odrl: + prefix void: + CONSTRUCT { ?S ?P ?O } WHERE { graph <$graph> { ?S ?P ?O . filter( + ?P = rdf:type || + ?P = rdfs:label || + ?P = rdfs:comment || + ?P = rdfs:subClassOf || + ?P = odrl:permission || + ?P = odrl:prohibition || + ?P = odrl:duty + + ) } } +QUERY; + $index = $store->query($q); + return $index['result']; + } + + public function bottom(){ + $q = << + prefix rdf: + PREFIX rdfs: + select ?concept ?label ?question where { + ?concept a . + filter(!bound(?child)) . + optional { + ?child rdfs:subClassOf ?concept + } + ?concept rdfs:comment ?question . + ?concept rdfs:label ?label + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows[0]; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function childrenQuestionsOf($question){ + $concept = $question['concept']; + $q = << + prefix rdf: + PREFIX rdfs: + select ?concept ?label ?question where { + ?concept a . + ?concept rdfs:subClassOf <$concept> . + ?concept rdfs:comment ?question . + ?concept rdfs:label ?label + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function parentQuestionsOf($question){ + $concept = $question['concept']; + $q = << + prefix rdf: + PREFIX rdfs: + select ?concept ?label ?question where { + ?concept a . + <$concept> rdfs:subClassOf ?concept. + ?concept rdfs:comment ?question . + ?concept rdfs:label ?label + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function questions(){ + + $q = << + prefix rdf: + PREFIX rdfs: + select ?concept ?label ?question where { + ?concept a . + ?concept rdfs:comment ?question . + ?concept rdfs:label ?label + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function question($uri){ + + $q = << + prefix rdf: + PREFIX rdfs: + select ?label ?question where { + <$uri> a . + <$uri> rdfs:comment ?question . + <$uri> rdfs:label ?label + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + $r = $rows[0]; + $r['concept'] = $uri; + return $r; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function licences($types = array()){ + + $fyes = ''; + foreach($types as $y): + $fyes .= ' ?licence a <' . $y . '> .' . "\n"; + endforeach; + + $graph = self::TAXONOMY; + $q = << + prefix rdf: + PREFIX rdfs: + prefix cc: + PREFIX void: + select ?licence ?label ?link where { + { + ?licence a odrl:Policy . + ?licence void:inDataset <$graph> . + $fyes + ?licence rdfs:label ?label . + optional { ?licence cc:legalcode ?link } + }union{ + ?licence a odrl:Set . + ?licence void:inDataset <$graph> . + $fyes + ?licence rdfs:label ?label . + optional { ?licence cc:legalcode ?link } + } + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); +// print_r($q); die; + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function policies($licence){ + $policies = array(); + $policies['permission'] = $this->permissions($licence); + $policies['prohibition'] = $this->prohibitions($licence); + $policies['duty'] = $this->duties($licence); + return $policies; + } + + public function permissions($licence){ + $q = << + prefix rdf: + PREFIX rdfs: + prefix cc: + select ?permission + where { + <$licence> odrl:permission ?permission . filter(isIRI(?permission)) + } +QUERY; + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + public function prohibitions($licence){ + $q = << + prefix rdf: + PREFIX rdfs: + prefix cc: + select ?prohibition where { + <$licence> odrl:prohibition ?prohibition . filter(isIRI(?prohibition)) + } +QUERY; + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + + public function duties($licence){ + $q = << + prefix rdf: + PREFIX rdfs: + prefix cc: + select ?duty where { + <$licence> odrl:duty ?duty . filter(isIRI(?duty)) + } +QUERY; + $store = $this->_store; + $rs = $store->query($q); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + return $rows; + }else{ + throw new DataAccessException($store->getErrors()); + } + } + + + public function licencesOfType($type){ + $q = << + prefix rdf: + PREFIX rdfs: + prefix cc: + select ?licence where { + { + <$type> ?licence . + } + } +QUERY; + + $store = $this->_store; + $rs = $store->query($q); + $licences = array(); + if (!$store->getErrors()) { + $rows = $rs['result']['rows']; + foreach($rows as $row): + array_push($licences, $row['licence']); + endforeach; + }else{ + throw new DataAccessException($store->getErrors()); + } + + return $licences; + } + + private static function parseIni(){ + return parse_ini_file ( dirname ( __FILE__ ) . '/dataaccess.ini', TRUE ); + } + + public static function instance() { + if (self::$_instance === NULL) { + self::$_instance = new DataAccess ( self::parseIni() ); + } + return self::$_instance; + } + + public static function rebuild(){ + self::$_instance = new DataAccess ( self::parseIni(), TRUE ); + return self::instance(); + } +} +class DataAccessException extends Exception { + private $_arcErrs = array (); + public function getARCErrors() { + return $this->_arcErrs; + } + public function __construct($errs = '') { + if (is_array ( $errs )) { + $this->_arcErrs = $errs; + $errs = implode ( "\n", $errs ); + } + parent::__construct ( $errs, 0, $this ); + } +} \ No newline at end of file diff --git a/html/actions.phtml b/html/actions.phtml new file mode 100644 index 0000000..2d94775 --- /dev/null +++ b/html/actions.phtml @@ -0,0 +1,7 @@ +

+

+get('actions', array()) as $label => $href): ?> + + +

+
\ No newline at end of file diff --git a/html/index.phtml b/html/index.phtml new file mode 100644 index 0000000..e7399e9 --- /dev/null +++ b/html/index.phtml @@ -0,0 +1,11 @@ +
+

Licence Picker

+

+

A tool for selecting the right licence for your data.

+ +

+ Start +

+
+ diff --git a/html/layout.phtml b/html/layout.phtml new file mode 100644 index 0000000..4ad3bc4 --- /dev/null +++ b/html/layout.phtml @@ -0,0 +1,85 @@ + + + + + + +<?php print $this->get('title'); ?> + + + + + + + + + + + + + + + + has('nav', FALSE)): ?> + partial('nav', array('nav' => $this->get('nav'))); ?> + +
+
+
+

+ get('title'); ?> +

+
+ has('breadcrumbs')): ?> +
+
+ partial('breadcrumbs', array('breadcrumbs' => $this->get('breadcrumbs',array()))); ?> +
+
+ +
+
+ partial('actions', array('actions' => $this->get('actions', array()), 'actions_select' => $this->get('actions_select', ''))); ?> +
+
+
+
+ partial('messages', array('messages'=> isset($_SESSION['messages']) ? $_SESSION['messages'] : array())); ?> +
+
+
+
+ partial($this->get('page'), $this->get('data', array())); ?> +
+
+
+
+ + diff --git a/html/messages.phtml b/html/messages.phtml new file mode 100644 index 0000000..80663db --- /dev/null +++ b/html/messages.phtml @@ -0,0 +1,22 @@ +get('messages', array()); +if(is_string($msg)){ + $msg = array('info'=>array($msg)); +} +?> + $ms): ?> + + + + + diff --git a/html/nav.phtml b/html/nav.phtml new file mode 100644 index 0000000..e94f574 --- /dev/null +++ b/html/nav.phtml @@ -0,0 +1,62 @@ + diff --git a/html/picker.phtml b/html/picker.phtml new file mode 100644 index 0000000..3edfef3 --- /dev/null +++ b/html/picker.phtml @@ -0,0 +1,158 @@ +
+ + + +

Answered (Yes: get('yes', array()));?>, No: get('no', array()));?>) + +get('stack'))>0): ?> +Restart + +

+ +get('yes', array())) == 0 && count($this->get('no', array())) == 0): ?> +

You can answer one of the questions below.

+ +
+ + get('yes', array()); + $noanswers = $this->get('no', array()); + $stack = $this->get('stack',array()); + // iterate over the stack to order the answers historically + ?> + $sv):?> + + + + + + +
+
+ +
+
+ Yes +
+
+ + + + + +
+
+ +
+
+ No +
+
+ + + + get('yes', array()) as $yes): ?> + + + +
+
+ +
+
+ Yes +
+
+ + + get('no', array()) as $no): ?> + + + +
+
+ +
+
+ No +
+
+ +
+get('questions', array())); +$isBottom = $this->get('isBottom'); +if($isBottom){ + // don't show the question + $qnb = 0; +} +?> +

Questions () +get('stack'))>0): ?> + + +

+
+ + get('questions', array()) as $question): ?> + +
+
+
+
+ + +
+
+
+ + +
You can choose one of the licences below.
+ +
+ +

Licences (get('licences', array()));?>)

+
+ + get('licences', array()) as $licence): ?> + +
+
+ + +

+ + $values): ?> + + + + + + + 0):?> +
+ + +
+
+ +
+
\ No newline at end of file diff --git a/http.inc b/http.inc new file mode 100644 index 0000000..2ad27c8 --- /dev/null +++ b/http.inc @@ -0,0 +1,55 @@ +getTraceAsString(); + } + error_log($echo); + return $echo; + +} +function redirect($location, $code = '303'){ + header("Location: $location", 303); + exit; +} \ No newline at end of file diff --git a/include.inc b/include.inc new file mode 100644 index 0000000..de86e20 --- /dev/null +++ b/include.inc @@ -0,0 +1,3 @@ + $v){ + $parameters .= '&' . $k .'=' . $v ; + } + return '?controller=' . $controller . '&action=' . $action . $parameters; +} +function router(){ + $params = array_merge($_GET, $_POST ); + $controller = 'default'; + if(isset($params['controller'])){ + $controller = $params['controller']; + }else{ + $params['controller'] = $controller; + } + $action = 'index'; + if(isset($params['action'])){ + $action = $params['action']; + }else{ + $params['action'] = $action; + } + + return array( + 'controller' => $controller , + 'action' => $action, + 'parameters' => $params ); +} + +function main(){ + require_once 'http.inc'; + require_once 'include.inc'; + try{ + $routing = router(); + $action = $routing['action']; + $controllerClass = controller($routing['controller']); + $controller = new $controllerClass (array('parameters' => $routing['parameters'])); + $controller->run(); + }catch(Exception $e){ + error_internal_server_error($e->getMessage()); + } +} +main(); diff --git a/mvctools.inc b/mvctools.inc new file mode 100644 index 0000000..4cadeed --- /dev/null +++ b/mvctools.inc @@ -0,0 +1,306 @@ +_parameters[$key] = $value; + } + + public function getParam($key, $default = FALSE){ + return $this->get($key, $default); + } + + public function has($key){ + return isset($this->_parameters[$key]) ? TRUE : FALSE; + } + + public function full($key){ + return ($this->has($key) && ( $this->get($key) != '' ) ); + } + + public function get($key, $default = FALSE){ + if( $this->has($key) ) { + return $this->_parameters[$key]; + }else{ + return $default; + } + } + + public function getAll(){ + return $this->_parameters; + } + + /** + * + * @param unknown $param + * @param unknown $itemKey + * @param string $default + */ + public function itemOf($key,$itemKey, $default = NULL){ + if($this->has($key) && is_array($this->get($key))){ + $a = $this->get($key); + if(array_key_exists($itemKey, $a)){ + return $a[$itemKey]; + } + } + return $default; + } +} +abstract class MVC_Controller extends MVC_Container{ + + protected $_action_parameter = 'action'; + // protected $_parameters = array(); + protected $_validators = array(); + protected $_sanitizers = array(); + public function __construct($args = array()){ + if(isset($args['action_parameter'])){ + $this->_action_parameter = $args['action_parameter']; + } + if(isset($args['parameters'])){ + $this->_parameters = $args['parameters']; + } + // Register shared validators + $this->setValidator('NotNull', new MVC_NotNullVal()); + $this->setValidator('NotEmpty', new MVC_NotEmptyVal()); + $this->setValidator('Int', new MVC_IntVal()); + + } + + public function indexAction(){ + // Nothing to do + } + + + + public function run(){ + if(isset($this->_parameters[$this->_action_parameter])){ + $this->perform($this->_parameters[$this->_action_parameter]); + }else{ + $this->perform('index'); + } + } + + public function perform($action){ + $method = $action . 'Action'; + if(method_exists($this, $method)){ + $this->$method(); + }else{ + $this->indexAction(); + } + } + + public function setValidator($name, MVC_Validator $validator){ + $this->_validators[$name] = $validator; + } + + public function setSanitizer($name, MVC_Sanitizer $sanitizer){ + $this->_sanitizers[$name] = $sanitizer; + } + + public function getValidator($name){ + return $this->_validators[$name]; + } + + public function getSanitizer(){ + return $this->_sanitizers[$name]; + } + + public function validate($validators){ + $errors = array(); + foreach($this->_parameters as $param => $value){ + if(isset($validators[$param])){ + foreach($validators[$param] as $validator){ + if($validator instanceof MVC_Validator){ + $tester = $validator; + }else{ + $tester = $this->getValidator($validator); + } + $result = $tester->test($value); + if($result !== TRUE){ + if(!isset($error[$param])){ + $errors[$param] = array(); + } + array_push($errors[$param], $result); + } + } + } + } + return $errors; + } + + private function applySan($result, $san){ + if($san instanceof MVC_Sanitizer){ + $result = $san->filter($result); + }else if(function_exists($san)){ + $result = @$san($result); + }else{ + $sanitizer = $this->getSanitizer($san); + $result = $sanitizer->filter($result); + } + return $result; + } + + public function sanitize($sanitizers){ + $errors = array(); + foreach($this->_parameters as $param => $value){ + if(isset($sanitizers[$param])){ + $result = $value; + if(is_array($sanitizers[$param])){ + foreach($sanitizers[$param] as $san){ + $result = $this->applySan($result, $san); + } + }else{ + $result = $this->applySan($result, $sanitizers[$param]); + } + $this->_parameters[$param] = $result; + } + } + } +} + + +interface MVC_Sanitizer{ + public function filter($val); +} + +interface MVC_Validator{ + public function test($val); +} + +class MVC_OneOfVal implements MVC_Validator{ + private $_mode = NULL; + private $_values = NULL; + public function __construct($values, $mode = TRUE){ + $this->_values = $values; + $this->_mode = $mode; + } + public function test($val){ + if (in_array($val, $this->_values) === $this->_mode) + return TRUE; + return 'Value ' . ( $this->_mode ? 'not in' : ' in ' ) . ' "' . join(', ', $this->_values) . '"'; + } + public function allowed(){ + $this->_mode = TRUE; + } + public function forbidden(){ + $this->_mode = FALSE; + } +} + +class MVC_CallbackVal implements MVC_Validator{ + private $_function = NULL; + public function __construct($func){ + if(function_exists($func)){ + $this->_function = $func; + } else throw new Exception('Function ' . $func . ' does not exist!'); + } + + public function test($val){ + return $this->_function($val); + } +} +class MVC_NotNullVal implements MVC_Validator{ + public function test($value){ + if($value === NULL){ + return "Cannot be null"; + } + return TRUE; + } +} +class MVC_NotEmptyVal implements MVC_Validator{ + public function test($value){ + if(empty($value) || $value == ''){ + return "Cannot be empty"; + } + return TRUE; + } +} +class MVC_IntVal implements MVC_Validator{ + public function test($value){ + if(strval(intval($value)) !== $value){ + return "Must be int, was: " . $value; + } + return TRUE; + } +} + +class MVC_Viewer extends MVC_Container{ + private $_templateDirectory; + + public function __construct ( $data = array() ){ + $this->_templateDirectory = dirname(__FILE__) . '/html'; + $this->_parameters = $data; + } + public function render($template){ + include $this->_templateDirectory . '/' . $template . '.phtml'; + } + + public function partial($template, $data = array()){ + $class = get_class($this); + $viewer = new $class($data); + $viewer->render($template); + } + + /** + * Prints the value of $key + * @param string $key + */ + public function spit($key){ + print $this->get($key); + } + + /** + * Prints the value of $key, encode special chars as HTML entities + * @param string $key + */ + public function smushed($key){ + print $this->smush($this->get($key)); + } + + /** + * Returns the passed value, encode special chars as HTML entities + * @param string $value + */ + public static function smush($value){ + return htmlspecialchars($value); + } + + public function spitMany(array $keys = array(), $sep = ' '){ + $first = TRUE; + foreach($kets as $key){ + if($first) $first = false; + else print $sep; + $this->spit($key); + } + } + +} + +class MVC_Html extends MVC_Viewer{ + public function spitAttr($key, $attr = ''){ + if($this->has($key)){ + if($attr == ''){ + $attr = $key; + } + print ' ' . $attr .'="' ; + $this->spit($key) ; + print '" '; + } + } + + public function spitAttrs(array $attrs = array('id', 'name', 'placeholder', 'class', 'style', 'type'), $prefix = ''){ + foreach($attrs as $attr){ + $_attr = $prefix . $attr; + $this->spitAttr($_attr, $attr); + } + } +} \ No newline at end of file diff --git a/resources/rdflicense-modified.ttl b/resources/rdflicense-modified.ttl new file mode 100644 index 0000000..8b1fec0 --- /dev/null +++ b/resources/rdflicense-modified.ttl @@ -0,0 +1,2504 @@ +@prefix cc: . +@prefix dct: . +@prefix owl: . +@prefix rdf: . +@prefix xml: . +@prefix xsd: . +@prefix foaf: . +@prefix rdf: . +@prefix odrl: . +@prefix ldr: . +@prefix skos: . +@prefix provo: . +@prefix rdfs: . +@prefix : . + +#uploaded 15.11.2014 +#GENERAL INFORMATION (NOT LICENSES) + + + a odrl:Policy ; + rdfs:label "All rights reserved"; + rdfs:comment "This license does not disclose any of the IPR and database rights" ; + odrl:prohibition [ + odrl:action + ldr:IPRRight, ldr:databaseRight; + ] . + + + a odrl:Policy ; + rdfs:label "Public domain"; + rdfs:comment "This statement can be applied to material truly in the public domain (because rights have expired, forfeited or are innaplicable)." ; + odrl:permission [ + odrl:action + ldr:IPRRight, ldr:databaseRight; + ] . + +#CREATIVE COMMONS LICENSES VERSION 4.0 + + + a odrl:Policy ; + dct:hasVersion "4.0" ; + rdfs:label "Creative Commons CC-BY 4.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "4.0" ; + rdfs:label "Creative Commons CC-BY-NC 4.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + odrl:prohibition [ + odrl:action cc:CommercialUse ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "4.0" ; + rdfs:label "Creative Commons CC-BY-ND 4.0"; + dct:language ; + odrl:permission [ + odrl:action cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + odrl:prohibition [ + odrl:action cc:DerivativeWorks ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "4.0" ; + rdfs:label "Creative Commons CC-BY-SA 4.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice , cc:ShareAlike + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "4.0" ; + rdfs:label "Creative Commons CC-BY-NC-SA 4.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks ,cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice , cc:ShareAlike + ] + ]; + odrl:prohibition [ + odrl:action cc:CommercialUse ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "4.0" ; + rdfs:label "Creative Commons CC-BY-NC-ND 4.0"; + dct:language ; + odrl:permission [ + odrl:action cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice #, cc:ShareAlike - XXX this should not apply + ] + ]; + odrl:prohibition [ + odrl:action cc:CommercialUse ; + odrl:action cc:DerivativeWorks ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "1.0" ; + rdfs:label "Creative Commons CC0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + ]; + cc:legalcode ; + rdfs:seeAlso . + +#CREATIVE COMMONS LICENSES VERSION 3.0 Unported + + a odrl:Policy ; + dct:hasVersion "3.0" ; + rdfs:label "Creative Commons CC-BY 3.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "3.0" ; + rdfs:label "Creative Commons CC-BY-NC 3.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + odrl:prohibition [ + odrl:action cc:CommercialUse ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "3.0" ; + rdfs:label "Creative Commons CC-BY-ND 3.0"; + dct:language ; + odrl:permission [ + odrl:action cc:Reproduction; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + odrl:prohibition [ + odrl:action cc:DerivativeWorks ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "3.0" ; + rdfs:label "Creative Commons CC-BY-SA 3.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice , cc:ShareAlike + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "3.0" ; + rdfs:label "Creative Commons CC-BY-NC-SA 3.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks ,cc:Reproduction ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice , cc:ShareAlike + ] + ]; + odrl:prohibition [ + odrl:action cc:CommercialUse ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "3.0" ; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0"; + dct:language ; + odrl:permission [ + odrl:action cc:Reproduction; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice #, cc:ShareAlike + ] + ]; + odrl:prohibition [ + odrl:action cc:CommercialUse ; + odrl:action cc:DerivativeWorks ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + +#OLDER CREATIVE COMMONS LICENSES + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 France"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Spain"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Greece"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Germany"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Netherlands"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Belgium"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Denmark"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Ireland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Italy"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Portugal"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Austria"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Australia"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Brazil"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Switzerland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Chile"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Venezuela"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 China"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Romania"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 3.0 Ecuador"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 France"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Spain"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Greece"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Germany"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Netherlands"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Belgium"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Denmark"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Ireland"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Italy"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Portugal"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Austria"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Australia"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Canada"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Brazil"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Switzerland"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Japan"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY 2.0 Chile"; + cc:legalcode ; + dct:hasVersion "2.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 France"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Spain"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Greece"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Germany"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Netherlands"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Belgium"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Denmark"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Ireland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Italy"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Portugal"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Austria"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Australia"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Brazil"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Switzerland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Chile"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Venezuela"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 China"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Romania"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-ND 3.0 Ecuador"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 France"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Spain"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Greece"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Germany"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Netherlands"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Ireland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Italy"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Portugal"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Austria"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Australia"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Brazil"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Switzerland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Chile"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Venezuela"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 China"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Romania"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-SA 3.0 Ecuador"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute, odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 France"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Spain"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Greece"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Germany"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Netherlands"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Ireland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Italy"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Portugal"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Austria"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Australia"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Brazil"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Switzerland"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Chile"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Venezuela"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 China"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Romania"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + a odrl:Set; + rdfs:label "Creative Commons CC-BY-NC-ND 3.0 Ecuador"; + cc:legalcode ; + dct:hasVersion "3.0" ; + dct:language ; + cc:jurisdiction ; + rdfs:seeAlso ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize, cc:DerivativeWorks + ] ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + +#OTHER LICENSES + + + a odrl:Policy ; + dct:hasVersion "1.0" ; + dct:language ; + rdfs:label "Open Data Commons Public Domain Dedication and License 1.0"; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "1.0" ; + dct:language ; + rdfs:label "Open Data Commons Attribution License 1.0"; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution ; + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "1.0" ; + dct:language ; + rdfs:label "Open Data Commons Open Database License 1.0"; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:ShareAlike + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Policy ; + rdfs:label "Open Government License v1.0"; + dct:hasVersion "1.0" ; + cc:jurisdiction ; + cc:legalcode ; + dct:language ; + odrl:permission [ + odrl:action odrl:derive , odrl:distribute , odrl:reproduce, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action odrl:attribute , odrl:attachPolicy + ] + ]; + skos:related ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:hasVersion "2.0" ; + rdfs:label "Open Government License v2.0"; + dct:language ; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction, ldr:extraction, ldr:reutilization ; + odrl:duty [ + odrl:action cc:Attribution , cc:Notice + ] + ]; + cc:legalcode ; + rdfs:seeAlso . + + + a odrl:Set; + dct:hasVersion "1.0" ; + rdfs:label "Public Domain Mark v1.0"; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute + ] . + + + a odrl:Set; + dct:hasVersion "1.0" ; + rdfs:label "UK NonCommercial Government License v1.0"; + dct:language ; + cc:legalcode ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy; + odrl:action odrl:distribute; + odrl:action odrl:derive + ] ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . + + + a odrl:Policy ; + dct:hasVersion "2.0" ; + dct:creator ; + cc:legalcode ; + foaf:logo ; + dct:language ; + rdfs:label "GNU General Public License"; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction ; + odrl:duty [ + odrl:action cc:SourceCode , cc:Notice, cc:Copyleft ; + ] + ]; + owl:sameAs ; + rdfs:seeAlso . + + + a odrl:Policy ; + dct:creator ; + dct:hasVersion "3.0" ; + cc:legalcode ; + foaf:logo ; + dct:language ; + rdfs:label "GNU General Public License"; + odrl:permission [ + odrl:action cc:DerivativeWorks , cc:Distribution , cc:Reproduction ; + odrl:duty [ + odrl:action cc:SourceCode , cc:Notice, cc:Copyleft ; + ] + ]; + owl:sameAs ; + rdfs:seeAlso . + + + + a odrl:Set; + rdfs:label "Common Public License"; + dct:hasVersion "1.0" ; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:derive; + odrl:action odrl:reproduce; + odrl:action odrl:sell + # XXX Are we sure the semantic of odrl:sell applies here? Or the intended meaning of the license is odrl:commercialize? + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + rdfs:label "IBM Public License"; + dct:hasVersion "1.0" ; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:derive; + odrl:action odrl:reproduce; + odrl:action odrl:sell; + # XXX Are we sure the semantic of odrl:sell applies here? Or the intended meaning of the license is odrl:commercialize? + odrl:action odrl:present; + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; No, because you can sub-license + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + rdfs:label "W3C Software Notice and License"; + dct:language ; + dct:hasVersion "1.0" ; + cc:legalcode ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:distribute; + odrl:action odrl:modify; + odrl:action odrl:copy + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + rdfs:label "CRYPTIX GENERAL LICENSE"; + dct:hasVersion "1.0" ; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:distribute; + odrl:action odrl:modify + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; No share alike, only attach policy + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "MICROSOFT REFERENCE SOURCE LICENSE"; + dct:hasVersion "1.0" ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:read + ] ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:modify; + odrl:action odrl:distribute + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "FREE BSD DOCUMENTATION LICENSE"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:distribute; + odrl:action odrl:modify + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "BSD LICENSE"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:distribute; + odrl:action odrl:modify + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "BOOST SOFTWARE LICENSE 1.0"; + dct:hasVersion "1.0" ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute; + odrl:action odrl:derive; + odrl:action odrl:present; + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; + odrl:action odrl:attachPolicy + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "ARTISTIC LICENSE 2.0"; + dct:hasVersion "2.0" ; + odrl:permission [ + a odrl:Permission ; + odrl:action odrl:modify, odrl:distribute, odrl:reproduce, odrl:derive ; + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:shareAlike + ] + . +# XXX Problem with the artistic license, for example (but not only): +# 1) you can modify without distribution, +# 2) or you can distribute without modifications +# 3) or you can modify and distribute if you Document differences AND: +# 3.1) Make it available to the copyright holder with the same license OR +# 3.2) Give it a different name and make it not interfere with the standard version OR +# 3.3) Share it with the same license +# but the above is still a simplification ... + + + a odrl:Set; + rdfs:label "ORACLE BERKELEY DB LICENSE"; + dct:language ; + cc:legalcode ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy; + odrl:action odrl:distribute; + odrl:action odrl:modify + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; + odrl:action odrl:attachPolicy; + odrl:action odrl:attachSource; # This is not 100% accurate, because it is enough to provide information about how to get the source code (freely) + ] . +# I don't understand this. Berkley DB is under "GNU AFFERO GENERAL PUBLIC LICENSE" +# Maybe this refers to the Berkley DB Java Edition + + + a odrl:Set; + rdfs:label "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE"; + cc:legalcode ; + dct:language ; + dct:hasVersion "1.0" ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:modify; + odrl:action odrl:distribute; + odrl:action odrl:derive + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:shareAlike; # "The Modifications that You create or to which You contribute are governed by the terms of this License. " + odrl:action odrl:attachSource; # This is not 100% accurate, because it is enough to provide information about how to get the source code (freely) + ] . + + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "MIT LICENSE"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:distribute; + odrl:action odrl:copy; + odrl:action odrl:modify; + odrl:action odrl:sell; + odrl:action odrl:present; # + + odrl:action odrl:use; # + + ] . + + + + + a odrl:Set; + rdfs:label "EUROPEAN COMMISSION COPYRIGHT"; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "GOVTRACK LICENSE"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; +# odrl:action odrl:attribute + ] ; + odrl:prohibition [ + a odrl:Prohibition; +# odrl:action odrl:distribute; +# odrl:action odrl:commercialize + ] . +# XXX I don't think the legal code says anything of this! + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "Open License (Licence Ouverte)"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy; + odrl:action odrl:reproduce; + odrl:action odrl:distribute; + odrl:action odrl:modify; + odrl:action odrl:extract; # + + odrl:action odrl:derive; # + + odrl:action odrl:commercialize + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "WEB NDL AUTHORITY LICENSE"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy; + odrl:action odrl:distribute + ] ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize + ] . +# XXX The link points to a web page in japanese. At least the dct:language is wrong... + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "ColorIURIS Copyright"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy; + odrl:action odrl:reproduce + ] ; + odrl:prohibition [ + a odrl:Prohibition; + odrl:action odrl:commercialize + ] . + + + a odrl:Set; + rdfs:label "APACHE LICENSE 2.0"; + dct:hasVersion "2.0" ; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:derive; + odrl:action odrl:distribute; + odrl:action odrl:present; + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike; + odrl:action odrl:attribute; + odrl:action odrl:attachPolicy + ] . +# XXX Apache 2.0 is not share alike + + + a odrl:Set; + rdfs:label "MOZILLA PUBLIC LICENSE 2.0"; + dct:language ; + dct:hasVersion "2.0" ; + dct:creator ; + cc:legalcode ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:present; # + + odrl:action odrl:modify; + odrl:action odrl:distribute; + odrl:action odrl:sell + ] . + + + a odrl:Set; + rdfs:label "ECLIPSE PUBLIC LICENSE 1.0"; + dct:hasVersion "1.0" ; + dct:creator ; + cc:legalcode ; + dct:language ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute; + odrl:action odrl:derive; + odrl:action odrl:sell + ] ; + odrl:duty [ + a odrl:Duty; +# odrl:action odrl:shareAlike # grant to sublicense is given + ] . + + + a odrl:Set; + cc:legalcode ; + dct:language ; + rdfs:label "OS OPEN DATA LICENSE"; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:reproduce; + odrl:action odrl:distribute; + odrl:action odrl:derive; + odrl:action odrl:commercialize + ] ; + odrl:duty [ + a odrl:Duty; + odrl:action odrl:attribute + ] . + + +a odrl:Set; + rdfs:label "GNU LESSER GENERAL PUBLIC LICENSE"; + cc:legalcode ; + dct:language ; + dct:hasVersion "3.0" ; + odrl:permission [ + a odrl:Permission; + odrl:action odrl:copy; + odrl:action odrl:distribute; + odrl:action odrl:modify + ] . + diff --git a/resources/taxonomy.ttl b/resources/taxonomy.ttl new file mode 100644 index 0000000..3747f47 --- /dev/null +++ b/resources/taxonomy.ttl @@ -0,0 +1,4700 @@ + . + """None""" . + """""" . + . + . + . + . + . + . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#CommercialUse""" . + """permission http://creativecommons.org/ns#CommercialUse""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.org/NET/ldr/ns#databaseRight""" . + """permission http://purl.org/NET/ldr/ns#databaseRight""" . + """permission http://purl.org/NET/ldr/ns#extraction""" . + """permission http://purl.org/NET/ldr/ns#extraction""" . + """permission http://purl.org/NET/ldr/ns#IPRRight""" . + """permission http://purl.org/NET/ldr/ns#IPRRight""" . + """permission http://purl.org/NET/ldr/ns#reutilization""" . + """permission http://purl.org/NET/ldr/ns#reutilization""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/commercialize""" . + """permission http://www.w3.org/ns/odrl/2/commercialize""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://creativecommons.org/ns#Reproduction""" . + """prohibition http://creativecommons.org/ns#Reproduction""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """prohibition http://purl.org/NET/ldr/ns#databaseRight""" . + """prohibition http://purl.org/NET/ldr/ns#databaseRight""" . + """prohibition http://purl.org/NET/ldr/ns#extraction""" . + """prohibition http://purl.org/NET/ldr/ns#extraction""" . + """prohibition http://purl.org/NET/ldr/ns#IPRRight""" . + """prohibition http://purl.org/NET/ldr/ns#IPRRight""" . + """prohibition http://purl.org/NET/ldr/ns#reutilization""" . + """prohibition http://purl.org/NET/ldr/ns#reutilization""" . + """prohibition http://www.editeur.org/onix-pl/extract-char""" . + """prohibition http://www.editeur.org/onix-pl/extract-char""" . + """prohibition http://www.editeur.org/onix-pl/extract-page""" . + """prohibition http://www.editeur.org/onix-pl/extract-page""" . + """prohibition http://www.editeur.org/onix-pl/extract-word""" . + """prohibition http://www.editeur.org/onix-pl/extract-word""" . + """prohibition http://www.w3.org/ns/odrl/2/aggregate""" . + """prohibition http://www.w3.org/ns/odrl/2/aggregate""" . + """prohibition http://www.w3.org/ns/odrl/2/annotate""" . + """prohibition http://www.w3.org/ns/odrl/2/annotate""" . + """prohibition http://www.w3.org/ns/odrl/2/anonymize""" . + """prohibition http://www.w3.org/ns/odrl/2/anonymize""" . + """prohibition http://www.w3.org/ns/odrl/2/append""" . + """prohibition http://www.w3.org/ns/odrl/2/append""" . + """prohibition http://www.w3.org/ns/odrl/2/appendTo""" . + """prohibition http://www.w3.org/ns/odrl/2/appendTo""" . + """prohibition http://www.w3.org/ns/odrl/2/archive""" . + """prohibition http://www.w3.org/ns/odrl/2/archive""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/concurrentUse""" . + """prohibition http://www.w3.org/ns/odrl/2/concurrentUse""" . + """prohibition http://www.w3.org/ns/odrl/2/copy""" . + """prohibition http://www.w3.org/ns/odrl/2/copy""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/digitize""" . + """prohibition http://www.w3.org/ns/odrl/2/digitize""" . + """prohibition http://www.w3.org/ns/odrl/2/display""" . + """prohibition http://www.w3.org/ns/odrl/2/display""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/execute""" . + """prohibition http://www.w3.org/ns/odrl/2/execute""" . + """prohibition http://www.w3.org/ns/odrl/2/export""" . + """prohibition http://www.w3.org/ns/odrl/2/export""" . + """prohibition http://www.w3.org/ns/odrl/2/extract""" . + """prohibition http://www.w3.org/ns/odrl/2/extract""" . + """prohibition http://www.w3.org/ns/odrl/2/extractChar""" . + """prohibition http://www.w3.org/ns/odrl/2/extractChar""" . + """prohibition http://www.w3.org/ns/odrl/2/extractPage""" . + """prohibition http://www.w3.org/ns/odrl/2/extractPage""" . + """prohibition http://www.w3.org/ns/odrl/2/extractWord""" . + """prohibition http://www.w3.org/ns/odrl/2/extractWord""" . + """prohibition http://www.w3.org/ns/odrl/2/grantUse""" . + """prohibition http://www.w3.org/ns/odrl/2/grantUse""" . + """prohibition http://www.w3.org/ns/odrl/2/index""" . + """prohibition http://www.w3.org/ns/odrl/2/index""" . + """prohibition http://www.w3.org/ns/odrl/2/install""" . + """prohibition http://www.w3.org/ns/odrl/2/install""" . + """prohibition http://www.w3.org/ns/odrl/2/license""" . + """prohibition http://www.w3.org/ns/odrl/2/license""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/move""" . + """prohibition http://www.w3.org/ns/odrl/2/move""" . + """prohibition http://www.w3.org/ns/odrl/2/play""" . + """prohibition http://www.w3.org/ns/odrl/2/play""" . + """prohibition http://www.w3.org/ns/odrl/2/present""" . + """prohibition http://www.w3.org/ns/odrl/2/present""" . + """prohibition http://www.w3.org/ns/odrl/2/print""" . + """prohibition http://www.w3.org/ns/odrl/2/print""" . + """prohibition http://www.w3.org/ns/odrl/2/read""" . + """prohibition http://www.w3.org/ns/odrl/2/read""" . + """prohibition http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://www.w3.org/ns/odrl/2/sell""" . + """prohibition http://www.w3.org/ns/odrl/2/sell""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/textToSpeech""" . + """prohibition http://www.w3.org/ns/odrl/2/textToSpeech""" . + """prohibition http://www.w3.org/ns/odrl/2/transform""" . + """prohibition http://www.w3.org/ns/odrl/2/transform""" . + """prohibition http://www.w3.org/ns/odrl/2/translate""" . + """prohibition http://www.w3.org/ns/odrl/2/translate""" . + """prohibition http://www.w3.org/ns/odrl/2/use""" . + """prohibition http://www.w3.org/ns/odrl/2/use""" . + """prohibition http://www.w3.org/ns/odrl/2/write""" . + """prohibition http://www.w3.org/ns/odrl/2/write""" . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + . + """NAll""" . + """Should the licence prohibit any kind of use (All rights reserved)?""" . + . + . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://creativecommons.org/ns#Reproduction""" . + """prohibition http://creativecommons.org/ns#Reproduction""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """prohibition http://purl.org/NET/ldr/ns#databaseRight""" . + """prohibition http://purl.org/NET/ldr/ns#databaseRight""" . + """prohibition http://purl.org/NET/ldr/ns#extraction""" . + """prohibition http://purl.org/NET/ldr/ns#extraction""" . + """prohibition http://purl.org/NET/ldr/ns#IPRRight""" . + """prohibition http://purl.org/NET/ldr/ns#IPRRight""" . + """prohibition http://purl.org/NET/ldr/ns#reutilization""" . + """prohibition http://purl.org/NET/ldr/ns#reutilization""" . + """prohibition http://www.editeur.org/onix-pl/extract-char""" . + """prohibition http://www.editeur.org/onix-pl/extract-char""" . + """prohibition http://www.editeur.org/onix-pl/extract-page""" . + """prohibition http://www.editeur.org/onix-pl/extract-page""" . + """prohibition http://www.editeur.org/onix-pl/extract-word""" . + """prohibition http://www.editeur.org/onix-pl/extract-word""" . + """prohibition http://www.w3.org/ns/odrl/2/aggregate""" . + """prohibition http://www.w3.org/ns/odrl/2/aggregate""" . + """prohibition http://www.w3.org/ns/odrl/2/annotate""" . + """prohibition http://www.w3.org/ns/odrl/2/annotate""" . + """prohibition http://www.w3.org/ns/odrl/2/anonymize""" . + """prohibition http://www.w3.org/ns/odrl/2/anonymize""" . + """prohibition http://www.w3.org/ns/odrl/2/append""" . + """prohibition http://www.w3.org/ns/odrl/2/append""" . + """prohibition http://www.w3.org/ns/odrl/2/appendTo""" . + """prohibition http://www.w3.org/ns/odrl/2/appendTo""" . + """prohibition http://www.w3.org/ns/odrl/2/archive""" . + """prohibition http://www.w3.org/ns/odrl/2/archive""" . + """prohibition http://www.w3.org/ns/odrl/2/concurrentUse""" . + """prohibition http://www.w3.org/ns/odrl/2/concurrentUse""" . + """prohibition http://www.w3.org/ns/odrl/2/copy""" . + """prohibition http://www.w3.org/ns/odrl/2/copy""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/digitize""" . + """prohibition http://www.w3.org/ns/odrl/2/digitize""" . + """prohibition http://www.w3.org/ns/odrl/2/display""" . + """prohibition http://www.w3.org/ns/odrl/2/display""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/execute""" . + """prohibition http://www.w3.org/ns/odrl/2/execute""" . + """prohibition http://www.w3.org/ns/odrl/2/export""" . + """prohibition http://www.w3.org/ns/odrl/2/export""" . + """prohibition http://www.w3.org/ns/odrl/2/extract""" . + """prohibition http://www.w3.org/ns/odrl/2/extract""" . + """prohibition http://www.w3.org/ns/odrl/2/extractChar""" . + """prohibition http://www.w3.org/ns/odrl/2/extractChar""" . + """prohibition http://www.w3.org/ns/odrl/2/extractPage""" . + """prohibition http://www.w3.org/ns/odrl/2/extractPage""" . + """prohibition http://www.w3.org/ns/odrl/2/extractWord""" . + """prohibition http://www.w3.org/ns/odrl/2/extractWord""" . + """prohibition http://www.w3.org/ns/odrl/2/grantUse""" . + """prohibition http://www.w3.org/ns/odrl/2/grantUse""" . + """prohibition http://www.w3.org/ns/odrl/2/index""" . + """prohibition http://www.w3.org/ns/odrl/2/index""" . + """prohibition http://www.w3.org/ns/odrl/2/install""" . + """prohibition http://www.w3.org/ns/odrl/2/install""" . + """prohibition http://www.w3.org/ns/odrl/2/license""" . + """prohibition http://www.w3.org/ns/odrl/2/license""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/move""" . + """prohibition http://www.w3.org/ns/odrl/2/move""" . + """prohibition http://www.w3.org/ns/odrl/2/play""" . + """prohibition http://www.w3.org/ns/odrl/2/play""" . + """prohibition http://www.w3.org/ns/odrl/2/present""" . + """prohibition http://www.w3.org/ns/odrl/2/present""" . + """prohibition http://www.w3.org/ns/odrl/2/print""" . + """prohibition http://www.w3.org/ns/odrl/2/print""" . + """prohibition http://www.w3.org/ns/odrl/2/read""" . + """prohibition http://www.w3.org/ns/odrl/2/read""" . + """prohibition http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://www.w3.org/ns/odrl/2/sell""" . + """prohibition http://www.w3.org/ns/odrl/2/sell""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/textToSpeech""" . + """prohibition http://www.w3.org/ns/odrl/2/textToSpeech""" . + """prohibition http://www.w3.org/ns/odrl/2/transform""" . + """prohibition http://www.w3.org/ns/odrl/2/transform""" . + """prohibition http://www.w3.org/ns/odrl/2/translate""" . + """prohibition http://www.w3.org/ns/odrl/2/translate""" . + """prohibition http://www.w3.org/ns/odrl/2/use""" . + """prohibition http://www.w3.org/ns/odrl/2/use""" . + """prohibition http://www.w3.org/ns/odrl/2/write""" . + """prohibition http://www.w3.org/ns/odrl/2/write""" . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + . + """http://purl.org/NET/rdflicense/allrightsreserved""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://creativecommons.org/ns#Reproduction""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """prohibition http://purl.org/NET/ldr/ns#databaseRight""" . + """prohibition http://purl.org/NET/ldr/ns#extraction""" . + """prohibition http://purl.org/NET/ldr/ns#IPRRight""" . + """prohibition http://purl.org/NET/ldr/ns#reutilization""" . + """prohibition http://www.editeur.org/onix-pl/extract-char""" . + """prohibition http://www.editeur.org/onix-pl/extract-page""" . + """prohibition http://www.editeur.org/onix-pl/extract-word""" . + """prohibition http://www.w3.org/ns/odrl/2/aggregate""" . + """prohibition http://www.w3.org/ns/odrl/2/annotate""" . + """prohibition http://www.w3.org/ns/odrl/2/anonymize""" . + """prohibition http://www.w3.org/ns/odrl/2/append""" . + """prohibition http://www.w3.org/ns/odrl/2/appendTo""" . + """prohibition http://www.w3.org/ns/odrl/2/archive""" . + """prohibition http://www.w3.org/ns/odrl/2/concurrentUse""" . + """prohibition http://www.w3.org/ns/odrl/2/copy""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/digitize""" . + """prohibition http://www.w3.org/ns/odrl/2/display""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/execute""" . + """prohibition http://www.w3.org/ns/odrl/2/export""" . + """prohibition http://www.w3.org/ns/odrl/2/extract""" . + """prohibition http://www.w3.org/ns/odrl/2/extractChar""" . + """prohibition http://www.w3.org/ns/odrl/2/extractPage""" . + """prohibition http://www.w3.org/ns/odrl/2/extractWord""" . + """prohibition http://www.w3.org/ns/odrl/2/grantUse""" . + """prohibition http://www.w3.org/ns/odrl/2/index""" . + """prohibition http://www.w3.org/ns/odrl/2/install""" . + """prohibition http://www.w3.org/ns/odrl/2/license""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/move""" . + """prohibition http://www.w3.org/ns/odrl/2/play""" . + """prohibition http://www.w3.org/ns/odrl/2/present""" . + """prohibition http://www.w3.org/ns/odrl/2/print""" . + """prohibition http://www.w3.org/ns/odrl/2/read""" . + """prohibition http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://www.w3.org/ns/odrl/2/sell""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/textToSpeech""" . + """prohibition http://www.w3.org/ns/odrl/2/transform""" . + """prohibition http://www.w3.org/ns/odrl/2/translate""" . + """prohibition http://www.w3.org/ns/odrl/2/use""" . + """prohibition http://www.w3.org/ns/odrl/2/write""" . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + """prohibition http://www.w3.org/ns/odrl/2/writeTo""" . + . + """C""" . + """Should the licence permit commercial use?""" . + . + . + . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#CommercialUse""" . + """permission http://creativecommons.org/ns#CommercialUse""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/commercialize""" . + """permission http://www.w3.org/ns/odrl/2/commercialize""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#CommercialUse""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/commercialize""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/OS""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#CommercialUse""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/commercialize""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """Public""" . + """Should the licence grant any right to the public domain?""" . + . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.org/NET/ldr/ns#databaseRight""" . + """permission http://purl.org/NET/ldr/ns#databaseRight""" . + """permission http://purl.org/NET/ldr/ns#extraction""" . + """permission http://purl.org/NET/ldr/ns#extraction""" . + """permission http://purl.org/NET/ldr/ns#IPRRight""" . + """permission http://purl.org/NET/ldr/ns#IPRRight""" . + """permission http://purl.org/NET/ldr/ns#reutilization""" . + """permission http://purl.org/NET/ldr/ns#reutilization""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.org/NET/ldr/ns#databaseRight""" . + """permission http://purl.org/NET/ldr/ns#extraction""" . + """permission http://purl.org/NET/ldr/ns#IPRRight""" . + """permission http://purl.org/NET/ldr/ns#reutilization""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.org/NET/ldr/ns#databaseRight""" . + """permission http://purl.org/NET/ldr/ns#extraction""" . + """permission http://purl.org/NET/ldr/ns#IPRRight""" . + """permission http://purl.org/NET/ldr/ns#reutilization""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """NDi+NMod""" . + """Should the licence prohibit the distribution and modification of the data?""" . + . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/allrightsreserved""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/MICROSOFT1.0""" . + """prohibition http://creativecommons.org/ns#Distribution""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """prohibition http://www.w3.org/ns/odrl/2/distribute""" . + """prohibition http://www.w3.org/ns/odrl/2/modify""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + """prohibition http://www.w3.org/ns/odrl/2/share""" . + . + """Grant Use""" . + """Should the licence permit to grant use of the data?""" . + . + . + . + . + . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/aggregate""" . + """permission http://www.w3.org/ns/odrl/2/annotate""" . + """permission http://www.w3.org/ns/odrl/2/anonymize""" . + """permission http://www.w3.org/ns/odrl/2/append""" . + """permission http://www.w3.org/ns/odrl/2/appendTo""" . + """permission http://www.w3.org/ns/odrl/2/archive""" . + """permission http://www.w3.org/ns/odrl/2/concurrentUse""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/digitize""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/execute""" . + """permission http://www.w3.org/ns/odrl/2/export""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/grantUse""" . + """permission http://www.w3.org/ns/odrl/2/index""" . + """permission http://www.w3.org/ns/odrl/2/install""" . + """permission http://www.w3.org/ns/odrl/2/license""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/move""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/textToSpeech""" . + """permission http://www.w3.org/ns/odrl/2/transform""" . + """permission http://www.w3.org/ns/odrl/2/translate""" . + """permission http://www.w3.org/ns/odrl/2/use""" . + """permission http://www.w3.org/ns/odrl/2/write""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + """permission http://www.w3.org/ns/odrl/2/writeTo""" . + . + """Copyleft""" . + """Should the licence require to share any derived or combined content under the same terms?""" . + . + . + . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """duty http://creativecommons.org/ns#Copyleft""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """Read""" . + """Should the licence permit to read (access) the data?""" . + . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """http://purl.org/NET/rdflicense/MICROSOFT1.0""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """permission http://www.w3.org/ns/odrl/2/read""" . + """permission http://www.w3.org/ns/odrl/2/read""" . + . + """ND""" . + """Should the licence prohibit derivative works?""" . + . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """http://purl.org/NET/rdflicense/allrightsreserved""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd3.0""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd4.0""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd3.0""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd4.0""" . + """prohibition http://creativecommons.org/ns#DerivativeWorks""" . + """prohibition http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + """prohibition http://www.w3.org/ns/odrl/2/derive""" . + . + """SRC""" . + """Should the licence require to attach the source code the asset?""" . + . + . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ORACLE1.0""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """duty http://creativecommons.org/ns#SourceCode""" . + """duty http://www.w3.org/ns/odrl/2/attachSource""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """Pre""" . + """Should the licence permit to present or display the data?""" . + . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/BOOST1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/IBM1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/MOZILLA2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/display""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/play""" . + """permission http://www.w3.org/ns/odrl/2/present""" . + """permission http://www.w3.org/ns/odrl/2/print""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """Sell""" . + """Should the licence permit to sell the data?""" . + . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/COMMON1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/ECLIPSE1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/IBM1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/MOZILLA2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """permission http://www.w3.org/ns/odrl/2/sell""" . + """permission http://www.w3.org/ns/odrl/2/sell""" . + . + """SA""" . + """Should the licence require to share the derived work under the same terms?""" . + . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ARTISTIC2.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/COMMON1.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbl1.0""" . + """duty http://creativecommons.org/ns#ShareAlike""" . + """duty http://www.w3.org/ns/odrl/2/shareAlike""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """NC""" . + """Should the licence prohibit any form of commercial use?""" . + . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/COLORIURIS1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/NDL1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """prohibition http://creativecommons.org/ns#CommercialUse""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + """prohibition http://www.w3.org/ns/odrl/2/commercialize""" . + . + """Mod""" . + """Should the licence permit to modify the data?""" . + . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ARTISTIC2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/BSD1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/CRYPTIX1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/FREEBSD1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/GNU-LGPL3.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/MOZILLA2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ORACLE1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/W3C1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/modify""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """A""" . + """Should the licence require credit to be given to copyright holder and/or author (attribution statement)?""" . + . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd3.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd4.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd3.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd4.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by3.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by4.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/EUC1.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbc-by1.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbl1.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OS""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ukogl2.0""" . + """duty http://creativecommons.org/ns#Attribution""" . + """duty http://www.w3.org/ns/odrl/2/attribute""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """N""" . + """Should the licence require to include copyright and license notices?""" . + . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/BOOST1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/BSD1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd4.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd4.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/cc-by4.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/COMMON1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/CRYPTIX1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/FREEBSD1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/IBM1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/ORACLE1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/ukogl2.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://purl.org/NET/rdflicense/W3C1.0""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """duty http://creativecommons.org/ns#Notice""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + """duty http://www.w3.org/ns/odrl/2/attachPolicy""" . + . + """D""" . + """Should the licence permit derivative works?""" . + . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ARTISTIC2.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/BOOST1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by3.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by4.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-zero1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/COMMON1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ECLIPSE1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/IBM1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbc-by1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbc-pddl1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbl1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OS""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/PDM1.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ukogl2.0""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """permission http://creativecommons.org/ns#DerivativeWorks""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Derivation""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/derive""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """Di""" . + """Should the licence permit the distribution/sharing of the data?""" . + . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ARTISTIC2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/BOOST1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/BSD1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-by3.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-by4.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/cc-zero1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/CRYPTIX1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ECLIPSE1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/FREEBSD1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/GNU-LGPL3.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/MOZILLA2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/NDL1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/odbc-by1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/odbc-pddl1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/odbl1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ORACLE1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/OS""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/PDM1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/ukogl2.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://purl.org/NET/rdflicense/W3C1.0""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """permission http://creativecommons.org/ns#Distribution""" . + """permission http://purl.oclc.org/NET/ldr/ns#Distribution""" . + """permission http://www.w3.org/ns/odrl/2/distribute""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """permission http://www.w3.org/ns/odrl/2/share""" . + """permission http://www.w3.org/ns/odrl/2/share""" . + . + """Re""" . + """Should the licence permit the reproduction (copy) of the data?""" . + . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ARTISTIC2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/BOOST1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-nd4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-by4.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/cc-zero1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/COLORIURIS1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/COMMON1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ECLIPSE1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/EUC1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/GNU-LGPL3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/IBM1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/MOZILLA2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/NDL1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbc-by1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbc-pddl1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/odbl1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ORACLE1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/OS""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/PDM1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/ukogl2.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://purl.org/NET/rdflicense/W3C1.0""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """permission http://creativecommons.org/ns#Reproduction""" . + """permission http://purl.oclc.org/NET/ldr/ns#Reproduction""" . + """permission http://www.editeur.org/onix-pl/extract-char""" . + """permission http://www.editeur.org/onix-pl/extract-page""" . + """permission http://www.editeur.org/onix-pl/extract-word""" . + """permission http://www.w3.org/ns/odrl/2/copy""" . + """permission http://www.w3.org/ns/odrl/2/extract""" . + """permission http://www.w3.org/ns/odrl/2/extractChar""" . + """permission http://www.w3.org/ns/odrl/2/extractPage""" . + """permission http://www.w3.org/ns/odrl/2/extractWord""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + """permission http://www.w3.org/ns/odrl/2/reproduce""" . + . + """Any""" . + """""" . + . + """http://purl.org/NET/rdflicense/allrightsreserved""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/APACHE2.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/ARTISTIC2.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/BOOST1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/BSD1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nc-nd4.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nc-sa4.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nc3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nc4.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nd3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-nd4.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-sa3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by-sa4.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-by4.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/cc-zero1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/CDDL1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/COLORIURIS1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/COMMON1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/CRYPTIX1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/ECLIPSE1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/EUC1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/FREEBSD1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/GNU-LGPL3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/GOVTRACK1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/gpl2.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/gpl3.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/IBM1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/MICROSOFT1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/MIT1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/MOZILLA2.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/NDL1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/odbc-by1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/odbc-pddl1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/odbl1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/OGL1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/OL1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/ORACLE1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/OS""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/PDM1.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/publicdomain""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/ukogl2.0""" . + """""" . + . + . + """http://purl.org/NET/rdflicense/W3C1.0""" . + """""" . + . + . + """http://www.gnu.org/licenses/gpl-2.0.rdf""" . + """""" . + . + . + """http://www.gnu.org/licenses/gpl-3.0.rdf""" . + """""" . + . diff --git a/styles/main.css b/styles/main.css new file mode 100644 index 0000000..fee8c3e --- /dev/null +++ b/styles/main.css @@ -0,0 +1,28 @@ +.item{ + padding:5px; +} +.item:hover{ + background-color: #f5f5f5; +} +.item-grey{ + background-color: #f0f0f0; +} +.item-grey:hover{ + background-color: #e5e5e5; +} + +.label-policy{ + margin: 0px 3px; + display: inline-block; +} + +.btn-fixed-width { + width: 50px; +} +h4 .btn-fixed-width{ + margin-right: 5px; +} + +.navbar .navbar-nav li a.ontology-link { + color: yellow +} \ No newline at end of file