/** * Helper Function for function buildXmlResult($vartable). Generates * an xml string for a single variable an their corresponding value. * * @param String $varname The variables name * @param Node $varvalue The value of the variable * @return String The xml string */ protected function _getBindingString($varname, $varvalue) { $binding = '<binding name="' . $varname . '">'; $value = '<unbound/>'; if ($varvalue instanceof BlankNode) { $value = '<bnode>' . $varvalue->getLabel() . '</bnode>'; } else { if ($varvalue instanceof Resource) { $value = '<uri>' . $varvalue->getUri() . '</uri>'; } else { if ($varvalue instanceof Literal) { $label = htmlspecialchars($varvalue->getLabel()); $value = '<literal>' . $label . '</literal>'; if ($varvalue->getDatatype() != null) { $value = '<literal datatype="' . $varvalue->getDatatype() . '">' . $label . '</literal>'; } if ($varvalue->getLanguage() != null) { $value = '<literal xml:lang="' . $varvalue->getLanguage() . '">' . $label . '</literal>'; } } } } $binding = $binding . $value . '</binding>'; return $binding; }
/** * @see \Saft\Rdf\Node */ public function equals(Node $toCompare) { // It only compares URIs, everything will be quit with false. if ($toCompare->isNamed()) { return $this->getUri() == $toCompare->getUri(); } return false; }
/** * create new node index * * @throws \Neo4j\Exception\HttpException * * @param \Neo4j\Node $node * @param string $key * @param string $value * * @return void */ public function index(Node $node, $key, $value) { $this->_uri = $this->_db->getBaseUri() . 'index/node/' . $key . '/' . $value; $this->_data = $node->getUri(); list($response, $http_code) = Request::post($this->_uri, $this->_data); if ($http_code != 201) { throw new \Neo4j\Exception\HttpException($http_code); } }
/** * @param string $value The Literal value * @param Node $datatype The datatype of the Literal (respectively defaults to xsd:string or rdf:langString) * @param string $lang The language tag of the Literal (optional) */ public function __construct($value, Node $datatype = null, $lang = null) { if ($value === null) { throw new \Exception('Literal value can\'t be null. Please use AnyPattern if you need a variable.'); } elseif (!is_string($value)) { throw new \Exception("The literal value has to be of type string"); } $this->value = $value; if ($lang !== null) { $this->lang = (string) $lang; } if ($lang !== null && $datatype !== null && $datatype->isNamed() && $datatype->getUri() !== self::$rdfLangString) { throw new \Exception('Language tagged Literals must have <' . self::$rdfLangString . '> datatype.'); } if ($datatype !== null) { $this->datatype = $datatype; } elseif ($lang !== null) { $this->datatype = new NamedNodeImpl(self::$rdfLangString); } else { $this->datatype = new NamedNodeImpl(self::$xsdString); } }