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 http://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/COPYRIGHTS 0000644 0001750 0001750 00000002105 14171574150 014413 0 ustar nilesh nilesh The Redland R package is copyright;
Copyright (C) 2014-2016 Regents of the University of California
This product includes Redland software (https://librdf.org/)
developed at the Institute for Learning and Research Technology,
University of Bristol, UK (http://www.bristol.ac.uk/).
Redland Software is copyright:
Copyright (C) 2000-2013 David Beckett
Copyright (C) 2000-2005 University of Bristol
and is included in this derivative product under the terms of the Apache 2 license, which
requires posting of a NOTICE file, which is included in this package.
Licensed 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.
redland/inst/NOTICE 0000644 0001750 0001750 00000001303 14171574167 013710 0 ustar nilesh nilesh This product includes Redland software (https://librdf.org/)
developed at the Institute for Learning and Research Technology,
University of Bristol, UK (http://www.bristol.ac.uk/).
Licensed 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.
redland/cleanup 0000755 0001750 0001750 00000000035 14172121607 013371 0 ustar nilesh nilesh #!/bin/sh
rm -f src/Makevars
redland/NAMESPACE 0000644 0001750 0001750 00000020274 14172102245 013237 0 ustar nilesh nilesh # Generated by roxygen2: do not edit by hand
S3method(roclet_output,roclet_mergeNamespace)
S3method(roclet_process,roclet_mergeNamespace)
S3method(roclet_tags,roclet_mergeNamespace)
export(addStatement)
export(executeQuery)
export(freeModel)
export(freeParser)
export(freeQuery)
export(freeQueryResults)
export(freeSerializer)
export(freeStatement)
export(freeStorage)
export(freeWorld)
export(getBlankNodeId)
export(getNodeType)
export(getNodeValue)
export(getQueryResultLimit)
export(getResults)
export(getTermType)
export(is.null.externalptr)
export(mergeNamespace_roclet)
export(parseFileIntoModel)
export(serializeToCharacter)
export(serializeToFile)
export(setNameSpace)
export(setQueryResultLimit)
export(writeResults)
exportClasses(Model)
exportClasses(Node)
exportClasses(Parser)
exportClasses(Query)
exportClasses(QueryResults)
exportClasses(Serializer)
exportClasses(Statement)
exportClasses(Storage)
exportClasses(World)
exportMethods(initialize)
import(methods)
import(roxygen2)
useDynLib(redland, .registration = TRUE)
export(librdf_copyright_string)
export(librdf_copyright_string_get)
export(librdf_digest_final)
export(librdf_digest_init)
export(librdf_digest_to_string)
export(librdf_digest_update)
export(librdf_digest_update_string)
export(librdf_free_digest)
export(librdf_free_hash)
export(librdf_free_iterator)
export(librdf_free_model)
export(librdf_free_node)
export(librdf_free_parser)
export(librdf_free_query)
export(librdf_free_query_results)
export(librdf_free_serializer)
export(librdf_free_statement)
export(librdf_free_storage)
export(librdf_free_stream)
export(librdf_free_uri)
export(librdf_free_world)
export(librdf_hash_to_string)
export(librdf_internal_test_error)
export(librdf_internal_test_warning)
export(librdf_iterator_end)
export(librdf_iterator_get_context)
export(librdf_iterator_get_object)
export(librdf_iterator_next)
export(librdf_log_message_code)
export(librdf_log_message_facility)
export(librdf_log_message_level)
export(librdf_log_message_locator)
export(librdf_log_message_message)
export(librdf_model_add)
export(librdf_model_add_statement)
export(librdf_model_add_statements)
export(librdf_model_add_string_literal_statement)
export(librdf_model_add_typed_literal_statement)
export(librdf_model_as_stream)
export(librdf_model_contains_context)
export(librdf_model_contains_statement)
export(librdf_model_context_add_statement)
export(librdf_model_context_add_statements)
export(librdf_model_context_as_stream)
export(librdf_model_context_remove_statement)
export(librdf_model_context_remove_statements)
export(librdf_model_find_statements)
export(librdf_model_find_statements_in_context)
export(librdf_model_get_arc)
export(librdf_model_get_arcs)
export(librdf_model_get_arcs_in)
export(librdf_model_get_arcs_out)
export(librdf_model_get_contexts)
export(librdf_model_get_feature)
export(librdf_model_get_source)
export(librdf_model_get_sources)
export(librdf_model_get_target)
export(librdf_model_get_targets)
export(librdf_model_has_arc_in)
export(librdf_model_has_arc_out)
export(librdf_model_load)
export(librdf_model_query_execute)
export(librdf_model_remove_statement)
export(librdf_model_set_feature)
export(librdf_model_size)
export(librdf_model_sync)
export(librdf_model_to_string)
export(librdf_model_transaction_commit)
export(librdf_model_transaction_rollback)
export(librdf_model_transaction_start)
export(librdf_new_digest)
export(librdf_new_hash)
export(librdf_new_hash_from_array_of_strings)
export(librdf_new_hash_from_string)
export(librdf_new_model)
export(librdf_new_model_from_model)
export(librdf_new_model_with_options)
export(librdf_new_node)
export(librdf_new_node_from_blank_identifier)
export(librdf_new_node_from_literal)
export(librdf_new_node_from_node)
export(librdf_new_node_from_normalised_uri_string)
export(librdf_new_node_from_typed_literal)
export(librdf_new_node_from_uri)
export(librdf_new_node_from_uri_local_name)
export(librdf_new_node_from_uri_string)
export(librdf_new_parser)
export(librdf_new_query)
export(librdf_new_query_from_query)
export(librdf_new_serializer)
export(librdf_new_statement)
export(librdf_new_statement_from_nodes)
export(librdf_new_statement_from_statement)
export(librdf_new_storage)
export(librdf_new_storage_from_storage)
export(librdf_new_uri)
export(librdf_new_uri_from_filename)
export(librdf_new_uri_from_uri)
export(librdf_new_world)
export(librdf_node_equals)
export(librdf_node_get_blank_identifier)
export(librdf_node_get_li_ordinal)
export(librdf_node_get_literal_value)
export(librdf_node_get_literal_value_as_latin1)
export(librdf_node_get_literal_value_datatype_uri)
export(librdf_node_get_literal_value_is_wf_xml)
export(librdf_node_get_literal_value_language)
export(librdf_node_get_type)
export(librdf_node_get_uri)
export(librdf_node_is_blank)
export(librdf_node_is_literal)
export(librdf_node_is_resource)
export(librdf_parser_check_name)
export(librdf_parser_get_accept_header)
export(librdf_parser_get_feature)
export(librdf_parser_get_namespaces_seen_count)
export(librdf_parser_get_namespaces_seen_prefix)
export(librdf_parser_get_namespaces_seen_uri)
export(librdf_parser_guess_name2)
export(librdf_parser_parse_as_stream)
export(librdf_parser_parse_counted_string_as_stream)
export(librdf_parser_parse_counted_string_into_model)
export(librdf_parser_parse_into_model)
export(librdf_parser_parse_string_as_stream)
export(librdf_parser_parse_string_into_model)
export(librdf_parser_set_feature)
export(librdf_query_execute)
export(librdf_query_get_limit)
export(librdf_query_get_offset)
export(librdf_query_results_as_stream)
export(librdf_query_results_finished)
export(librdf_query_results_get_binding_name)
export(librdf_query_results_get_binding_value)
export(librdf_query_results_get_binding_value_by_name)
export(librdf_query_results_get_bindings_count)
export(librdf_query_results_get_boolean)
export(librdf_query_results_get_count)
export(librdf_query_results_is_bindings)
export(librdf_query_results_is_boolean)
export(librdf_query_results_is_graph)
export(librdf_query_results_is_syntax)
export(librdf_query_results_next)
export(librdf_query_results_to_file2)
export(librdf_query_results_to_string2)
export(librdf_query_set_limit)
export(librdf_query_set_offset)
export(librdf_serializer_check_name)
export(librdf_serializer_get_feature)
export(librdf_serializer_serialize_model_to_file)
export(librdf_serializer_serialize_model_to_string)
export(librdf_serializer_serialize_stream_to_file)
export(librdf_serializer_serialize_stream_to_string)
export(librdf_serializer_set_feature)
export(librdf_serializer_set_namespace)
export(librdf_short_copyright_string)
export(librdf_short_copyright_string_get)
export(librdf_statement_equals)
export(librdf_statement_get_object)
export(librdf_statement_get_predicate)
export(librdf_statement_get_subject)
export(librdf_statement_is_complete)
export(librdf_statement_match)
export(librdf_statement_set_object)
export(librdf_statement_set_predicate)
export(librdf_statement_set_subject)
export(librdf_stream_end)
export(librdf_stream_get_object)
export(librdf_stream_next)
export(librdf_uri_compare)
export(librdf_uri_equals)
export(librdf_uri_to_string)
export(librdf_version_decimal)
export(librdf_version_decimal_get)
export(librdf_version_major)
export(librdf_version_major_get)
export(librdf_version_minor)
export(librdf_version_minor_get)
export(librdf_version_release)
export(librdf_version_release_get)
export(librdf_version_string)
export(librdf_version_string_get)
export(librdf_world_get_feature)
export(librdf_world_open)
export(librdf_world_set_feature)
export(librdf_world_set_logger)
export(raptor_locator_byte)
export(raptor_locator_column)
export(raptor_locator_file)
export(raptor_locator_line)
export(raptor_locator_uri)
export(raptor_version_decimal)
export(raptor_version_decimal_get)
export(raptor_version_major)
export(raptor_version_major_get)
export(raptor_version_minor)
export(raptor_version_minor_get)
export(raptor_version_release)
export(raptor_version_release_get)
export(raptor_version_string)
export(raptor_version_string_get)
export(rasqal_version_decimal)
export(rasqal_version_decimal_get)
export(rasqal_version_major)
export(rasqal_version_major_get)
export(rasqal_version_minor)
export(rasqal_version_minor_get)
export(rasqal_version_release)
export(rasqal_version_release_get)
export(rasqal_version_string)
export(rasqal_version_string_get)