Beispiel #1
0
 public function testInitWithLabel()
 {
     $literal1 = Erfurt_Rdf_Literal::initWithLabel("Testliteral1");
     $literal2 = Erfurt_Rdf_Literal::initWithLabel("Testliteral2");
     $this->assertSame("Testliteral1", $literal1->getLabel());
     $this->assertSame("Testliteral2", $literal2->getLabel());
 }
Beispiel #2
0
 /**
  * Parses a literal.
  *
  * @param string $node
  * @param string $sep used separator " or '
  */
 protected function _parseLiteral(&$node, $sep)
 {
     if ($sep !== null) {
         do {
             next($this->_tokens);
             $node = $node . current($this->_tokens);
         } while (current($this->_tokens) != $sep);
         $this->_checkDtypeLang($node, strlen($sep));
     } else {
         $datatype = '';
         if (is_string($node) && strpos($node, '.') !== false) {
             $datatype = EF_XSD_NS . 'integer';
         } else {
             $datatype = EF_XSD_NS . 'decimal';
         }
         require_once 'Erfurt/Rdf/Literal.php';
         $node = Erfurt_Rdf_Literal::initWithLabel($node);
         $node->setDatatype($datatype);
     }
 }
Beispiel #3
0
 protected function _parseQuotedLiteral()
 {
     $label = $this->_parseQuotedString();
     $c = $this->_peek();
     if ($c === '@') {
         $this->_read();
         $lang = '';
         $c = $this->_read();
         if (!$this->_isLanguageStartChar($c)) {
             throw new Erfurt_Syntax_RdfParserException('Character "' . $c . '" not allowed as starting char in language tags.');
         }
         $lang .= $c;
         $c = $this->_read();
         while ($c !== -1 && !$this->_isWS($c) && !($c === ',') && !($c === '.')) {
             if (!$this->_isLanguageChar($c)) {
                 throw new Erfurt_Syntax_RdfParserException('Character "' . $c . '" not allowed in language tags.');
             }
             $lang .= $c;
             $c = $this->_read();
         }
         $this->_unread();
         require_once 'Erfurt/Rdf/Literal.php';
         return Erfurt_Rdf_Literal::initWithLabelAndLanguage($label, $lang);
     } else {
         if ($c === '^') {
             $this->_read();
             $this->_verifyChar($this->_read(), '^');
             $datatype = $this->_parseValue();
             if ($datatype instanceof Erfurt_Rdf_Resource) {
                 require_once 'Erfurt/Rdf/Literal.php';
                 return Erfurt_Rdf_Literal::initWithLabelAndDatatype($label, (string) $datatype);
             } else {
                 $this->_throwException('Illegal datatype value.');
                 return null;
             }
         } else {
             require_once 'Erfurt/Rdf/Literal.php';
             return Erfurt_Rdf_Literal::initWithLabel($label);
         }
     }
 }