Questions tagged [rdf]

The Resource Description Framework (RDF) is a language for representing information about resources in the World Wide Web. It is a syntax independent data model that may be serialised in a variety of concrete syntaxes. RDF is the core data format used on the Semantic Web.

The Resource Description Framework (RDF) is a language for representing information about resources in the World Wide Web. It is a syntax independent data model that may be serialised in a variety of concrete syntaxes. RDF is the core data format used on the Semantic Web.

Data Model

The data model for RDF is Graph based. Every fact in the data is represented as a Triple (or Statement) composed of a Subject, Predicate and Object. The Subject and Object can be thought of as nodes in the Graph while the Predicate is an arc in the Graph. Graphs are composed of a set of Triples, note that duplicates have no meaning.

Subjects must be resources which can either be named (using a IRI) or anonymous (known as Blank Nodes). IRIs are considered to be globally scoped while Blank Nodes are scoped to the Graph in which they appear.

Predicates must always be named resources i.e. IRIs.

Objects may be resources - IRIs/Blank Nodes - or they may be Literal values. Literal values are of three types:

  1. Simple Literals - These are just strings e.g. "simple literal"
  2. Literals with Language Specifiers - These are strings with the language of strings specified using standard language tags e.g. "literal with language tag"@en-gb
  3. Literals with DataTypes - These are values with a declared data type e.g. "123"^^xsd:integer . XML Schema DataTypes are commonly used and supported by related standards like SPARQL

Syntaxes

RDF is a syntax independent model but has a variety of officially and semi-officially standardised concrete syntaxes which are used to serialise it.

Official Standards (W3C)

The following are official standards created by the W3C

  • RDF/XML is the official XML based serialisation of RDF. RDF/XML is quite commonly used but has some drawbacks in being difficult for a human to understand or write by hand.
  • NTriples is the official plain text format for serialising RDF. It is a very simple serialisation that uses no syntactic sugar, it is very quick to parse and can be read/written by hand. It's disadvantage is that it is very verbose compared to other syntaxes.
  • RDFa is the officially recommended mechanism for embedding RDF into existing (X)HTML web pages. It is easy to use once learned but is sometimes criticised for the fact that the DOM structures required to embed RDFa often don't fit with the DOM structures of pages forcing developers to embed additional hidden elements with the RDFa.
  • Turtle is a readable yet compact plain text serialisation of RDF developed by Dave Beckett who was one of the members of the W3C working group that created the RDF specifications. It is quick and easy to parse and includes various syntactic sugar for compressing the data to make it less verbose. Turtle is a superset of NTriples and a subset of Notation 3 Turtle was introduces as an official RDF serialization in February 2014.
  • JSON-LD - JSON-LD is another JSON serialisation of RDF. It emphasises compact syntax and the ability to add RDF into your existing JSON data. It becamse official along with Turtle in February 2014.

Unofficial Standards

While the following are not officially standardised they are reasonably well specified and are widely implemented in RDF/Semantic Web APIs:

  • Notation 3 is a readable yet compact plain text serialisation of RDF developed by Tim Berners-Lee. It is a superset of Turtle and is capable of expressing data which is outside of the core RDF model as well as expressing all valid RDF.
  • Talis RDF/JSON - One of several competing JSON serialisations of RDF that tries to be as compact as possible

Resources

4248 questions
28
votes
3 answers

What is the relationship between RDF, RDFa, Microformats and Microdata

I've done quite a bit of research but I can't understand the exact relationship between the 3. Also, now that W3C has officially recognised RDFa, would you recommend it over Microdata, taking into consideration that it matches Microdata's features…
aelsheikh
  • 2,268
  • 5
  • 26
  • 41
24
votes
3 answers

Is it possible to get the position of an element in an RDF Collection in SPARQL?

Suppose that I have the following Turtle declaration: @prefix : . :ls :list (:a :b :c) Is there a way to get the positions of the elements in the collection? For example, with this query: PREFIX : …
Labra
  • 1,412
  • 1
  • 13
  • 33
23
votes
11 answers

Examples of using semantic web technologies in real world applications

Are you working on a (probably commercial) product which uses RDF/OWL/SPARQL technologies? If so, can you please describe your product?
caustic
  • 1,749
  • 2
  • 16
  • 7
23
votes
1 answer

Comments in SPARQL query?

Can I write comments in a query, so that only God but also me remember what I was doing? I just started learning SPARQL, so forgive my ignorance. For example: SELECT ?names WHERE { ?names dbo:award :Turing_Award // get names that won Turing…
gsamaras
  • 71,951
  • 46
  • 188
  • 305
23
votes
10 answers

What is the best way to learn about RDF / OWL?

What references offer a good summary/tutorial for using RDF/OWL? There seem to be enough tools (Protege, Topbraid, Jena, etc.) that knowing the syntax of the markup languages is not necessary, but knowing the concepts is, of course, still critical.…
rcreswick
  • 16,483
  • 15
  • 59
  • 70
22
votes
3 answers

The best tool for visualizing ontologies?

I am looking to visualize ontologies for understanding and making others understand. I would prefer to have top-down hierarchy of classes. I have used OntoGraph which comes with Protégé, but I am not happy with the figure :(. I have also used…
PCoder
  • 2,165
  • 3
  • 23
  • 32
22
votes
2 answers

Where do I test my queries for my RDF written in SPARQL

I am a beginner with Semantic Web technologies, My question might be a very basic one but I am really stuck figuring it out. I have a RDF file I created from an XML and have validated it using w3.org RDF VALIDATOR. My question is how can I run…
Yaba
  • 304
  • 1
  • 3
  • 15
21
votes
1 answer

SPARQL property path queries with arbitrary properties

SPARQL property path queries of arbitrary length require using specific properties. I want to query and find any path starting from a resource and ending in another resource. For example: SELECT ?p WHERE { :startNode ?p* :endNode } where ?p*…
user3287385
  • 213
  • 2
  • 5
21
votes
5 answers

The best PHP lib/class to generate RSS/Atom

I have to produce an RSS/Atom feed in various applications, and I want to know a good library or class which is able to produce both, and which already handles all common problems. For example, the one I used for years does not put the right format…
Cédric Girard
  • 3,358
  • 7
  • 37
  • 52
21
votes
2 answers

Select multiple values as object in SPARQL pattern

In SPARQL we can do something like this select * where { ?s (_:prop1 | _:prop2) "some_val" . ... #use ?s in other patterns ?s ?o ?p . } Is it possible to do the same for the object part of the pattern? And what are some…
0xFF
  • 4,140
  • 7
  • 41
  • 58
20
votes
3 answers

SPARQL select optional with language

I have some triples that look like this: test:thing rdfs:label "Non-Language Label" test:thing rdfs:label "English Label"@en test:thing rdfs:label "French Label"@fr I'd like to form a sparql query that gives me the "Non-Language Label" AND the…
Devin McQueeney
  • 1,277
  • 2
  • 14
  • 31
20
votes
6 answers

Parse large RDF in Python

I'd like to parse a very large (about 200MB) RDF file in python. Should I be using sax or some other library? I'd appreciate some very basic code that I can build on, say to retrieve a tag. Thanks in advance.
usertest
  • 27,132
  • 30
  • 72
  • 94
18
votes
3 answers

Querying WikiData, difference between p and wdt default prefix

I am new to wikidata and I can't figure out when I should use --> wdt prefix (http://www.wikidata.org/prop/direct/) and when I should use --> p prefix (http://www.wikidata.org/prop/). in my sparql queries. Can someone explain what each of these…
Bahar
  • 770
  • 5
  • 18
18
votes
3 answers

The difference between blank nodes and variables in SPARQL queries

I've studied SPARQL specification on the topic and also found this answer rather interesting. However definitions are complicated enough, so I still don't see the answer for my question. I can't find any example of query with blank nodes that…
Andy White
  • 183
  • 1
  • 5