Community Documentation

RDF API tutorials

Last updated February 17, 2008. Created by Arto on February 15, 2008.
Log in to edit this page.

The following examples illustrate RDF API usage.

Language-tagged literals

To create language-tagged plain literals, you can use the rdf_literal() API function as follows:

<?php
rdf_literal
('Hello!', 'en');
rdf_literal('Wazup?', 'en-US');
rdf_literal('¡Hola!', 'es');
?>

Datatyped literals

When dealing with datatyped literals, RDF API functions allow you to work with standard PHP types for those cases where an obvious mapping exists between the PHP type and an equivalent XML Schema type; these are as follows:

boolean
XSD serialization: xsd:boolean
XSD unserialization: xsd:boolean
integer
XSD serialization: xsd:integer
XSD unserialization: xsd:integer, xsd:long, xsd:unsignedLong, xsd:unsignedInt
double
XSD serialization: xsd:double
XSD unserialization: xsd:double, xsd:float, xs:decimal
string
XSD serialization: xsd:string
XSD unserialization: xsd:string, xsd:normalizedString, xsd:token, xsd:language

For dealing with any other datatyped literals, wrap the lexical representation using rdf_literal(); some examples follow.

Base-64 encoded data

<?php
rdf_literal
(base64_encode($text), NULL, xsd::base64Binary);
?>

Dates and times

<?php
rdf_literal
('2007-12-31T23:59:59Z', NULL, xsd::dateTime);
rdf_literal('2007-12-31', NULL, xsd::date);
rdf_literal('23:59:59.123-06:00', NULL, xsd::time);
?>

About this page

Drupal version
Drupal 6.x

Develop for Drupal

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here