Introduction
The redland R package provides methods to create, query
and write to disk data stored in the Resource Description Framework
(RDF). RDF provides a standardized way to make statements about
resources and the relationships between them. Typical resources include
datasets that are available via URLs. Resources don’t have to be
available online, for example a resource could also be the name of the
person that created a dataset. A collection of RDF statements comprise
an RDF graph, which can be read and interpreted by an RDF capable
software application that uses the resources described in the graph.
An introduction to RDF can be found at https://www.w3.org/TR/2014/NOTE-rdf11-primer-20140624/.
Examples
The following example reads an RDF graph from a disk file that was
previously saved in the RDF/XML format:
library(redland)
world <- new("World")
storage <- new("Storage", world, "hashes", name="", options="hash-type='memory'")
model <- new("Model", world=world, storage, options="")
parser <- new("Parser", world)
parseFileIntoModel(parser, world, system.file("extdata", "dc.rdf", package="redland"), model)
Next the RDF graph is queried for statements of interest, using the
SPARQL query
syntax
queryString <- 'PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?a ?c WHERE { ?a dc:creator ?c . }'
query <- new("Query", world, queryString, base_uri=NULL, query_language="sparql", query_uri=NULL)
queryResult <- executeQuery(query, model)
results <- getResults(query, model, "rdfxml")
cat(sprintf("Results from query: %s\n", results))
## Results from query: <?xml version="1.0" encoding="utf-8"?>
## <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
## xmlns:rs="http://www.w3.org/2001/sw/DataAccess/tests/result-set#">
## <rs:ResultSet>
## <rs:resultVariable>a</rs:resultVariable>
## <rs:resultVariable>c</rs:resultVariable>
## <rs:solution>
## <rdf:Description>
## <rs:binding>
## <rdf:Description>
## <rs:value rdf:resource="http://www.dajobe.org/"/>
## <rs:variable>a</rs:variable>
## </rdf:Description>
## </rs:binding>
## <rs:binding>
## <rdf:Description>
## <rs:value>Dave Beckett</rs:value>
## <rs:variable>c</rs:variable>
## </rdf:Description>
## </rs:binding>
## </rdf:Description>
## </rs:solution>
## </rs:ResultSet>
## </rdf:RDF>
Next, additional statements can be added to the RDF graph:
stmt <- new("Statement", world=world,
subject="http://www.dajobe.org/",
predicate="http://purl.org/dc/elements/1.1/language",
object="en")
addStatement(model, stmt)
## [1] 0
Now the RDF graph can be written to disk:
serializer <- new("Serializer", world, mimeType="application/rdf+xml")
status <- setNameSpace(serializer, world, namespace="http://purl.org/dc/elements/1.1/", prefix="dc")
filePath <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = ".rdf")
status <- serializeToFile(serializer, world, model, filePath)
redland/inst/config.log 0000644 0001762 0000144 00000045336 12535362125 014627 0 ustar ligges users This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by redland configure 1.0.14, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure
## --------- ##
## Platform. ##
## --------- ##
hostname = frost.local
uname -m = x86_64
uname -r = 14.3.0
uname -s = Darwin
uname -v = Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64
/usr/bin/uname -p = i386
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = Mach kernel version:
Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64
Kernel configured for up to 8 processors.
4 processors are physically available.
8 processors are logically available.
Processor type: x86_64h (Intel x86-64h Haswell)
Processors active: 0 1 2 3 4 5 6 7
Primary memory available: 16.00 gigabytes
Default processor set: 314 tasks, 1698 threads, 8 processors
Load average: 1.51, Mach factor: 6.48
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /opt/local/bin
PATH: /opt/local/sbin
PATH: /Users/jones/.rvm/gems/ruby-2.1.1/bin
PATH: /Users/jones/.rvm/gems/ruby-2.1.1@global/bin
PATH: /Users/jones/.rvm/rubies/ruby-2.1.1/bin
PATH: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin
PATH: /Library/Anaconda/bin
PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /Library/anaconda/bin
PATH: /usr/local/sbin
PATH: /opt/local/bin
PATH: /opt/local/sbin
PATH: /opt/local/lib/postgresql84/bin/
PATH: /Users/jones/development/dataone/allsoftware/tools/docutils
PATH: /usr/texbin
PATH: /Users/jones/.rvm/bin
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2252: checking for a BSD-compatible install
configure:2320: result: /opt/local/bin/ginstall -c
configure:2331: checking whether build environment is sane
configure:2386: result: yes
configure:2537: checking for a thread-safe mkdir -p
configure:2576: result: /opt/local/bin/gmkdir -p
configure:2583: checking for gawk
configure:2599: found /opt/local/bin/gawk
configure:2610: result: gawk
configure:2621: checking whether make sets $(MAKE)
configure:2643: result: yes
configure:2672: checking whether make supports nested variables
configure:2689: result: yes
configure:2817: checking whether to enable maintainer-specific portions of Makefiles
configure:2826: result: no
configure:2892: checking for gcc
configure:2908: found /usr/bin/gcc
configure:2919: result: gcc
configure:3148: checking for C compiler version
configure:3157: gcc --version >&5
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
configure:3168: $? = 0
configure:3157: gcc -v >&5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
configure:3168: $? = 0
configure:3157: gcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3168: $? = 1
configure:3157: gcc -qversion >&5
clang: error: unknown argument: '-qversion'
clang: error: no input files
configure:3168: $? = 1
configure:3188: checking whether the C compiler works
configure:3210: gcc conftest.c >&5
configure:3214: $? = 0
configure:3262: result: yes
configure:3265: checking for C compiler default output file name
configure:3267: result: a.out
configure:3273: checking for suffix of executables
configure:3280: gcc -o conftest conftest.c >&5
configure:3284: $? = 0
configure:3306: result:
configure:3328: checking whether we are cross compiling
configure:3336: gcc -o conftest conftest.c >&5
configure:3340: $? = 0
configure:3347: ./conftest
configure:3351: $? = 0
configure:3366: result: no
configure:3371: checking for suffix of object files
configure:3393: gcc -c conftest.c >&5
configure:3397: $? = 0
configure:3418: result: o
configure:3422: checking whether we are using the GNU C compiler
configure:3441: gcc -c conftest.c >&5
configure:3441: $? = 0
configure:3450: result: yes
configure:3459: checking whether gcc accepts -g
configure:3479: gcc -c -g conftest.c >&5
configure:3479: $? = 0
configure:3520: result: yes
configure:3537: checking for gcc option to accept ISO C89
configure:3600: gcc -c -g -O2 conftest.c >&5
configure:3600: $? = 0
configure:3613: result: none needed
configure:3638: checking whether gcc understands -c and -o together
configure:3660: gcc -c conftest.c -o conftest2.o
configure:3663: $? = 0
configure:3660: gcc -c conftest.c -o conftest2.o
configure:3663: $? = 0
configure:3675: result: yes
configure:3703: checking for style of include used by make
configure:3731: result: GNU
configure:3757: checking dependency style of gcc
configure:3868: result: none
configure:3888: checking for R
configure:3904: found /usr/bin/R
configure:3915: result: R
configure:3930: checking for pkg-config
configure:3946: found /opt/local/bin/pkg-config
configure:3957: result: pkg-config
configure:3970: checking for redland
configure:3977: result: 1.0.15
configure:3993: checking for raptor_parse in -lraptor2
configure:4018: gcc -o conftest -g -O2 conftest.c -lraptor2 >&5
ld: library not found for -lraptor2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4018: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "redland"
| #define PACKAGE_TARNAME "redland"
| #define PACKAGE_VERSION "1.0.14"
| #define PACKAGE_STRING "redland 1.0.14"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "redland"
| #define VERSION "1.0.14"
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char raptor_parse ();
| int
| main ()
| {
| return raptor_parse ();
| ;
| return 0;
| }
configure:4027: result: no
configure:4038: checking for rasqal_new_world in -lrasqal
configure:4063: gcc -o conftest -g -O2 conftest.c -lrasqal >&5
ld: library not found for -lrasqal
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4063: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "redland"
| #define PACKAGE_TARNAME "redland"
| #define PACKAGE_VERSION "1.0.14"
| #define PACKAGE_STRING "redland 1.0.14"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "redland"
| #define VERSION "1.0.14"
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char rasqal_new_world ();
| int
| main ()
| {
| return rasqal_new_world ();
| ;
| return 0;
| }
configure:4072: result: no
configure:4090: checking how to run the C preprocessor
configure:4121: gcc -E conftest.c
configure:4121: $? = 0
configure:4135: gcc -E conftest.c
conftest.c:11:10: fatal error: 'ac_nonexistent.h' file not found
#include