RdfSyntax
RDF has no single syntax; RDF is just a standard way of modeling ideas. That said, it's gotta be expressed.
RDF Serializations
(Trying to make this list as comprehensive as possible. If you know of one I've missed, link to it here.)
Various forms are:
- XML-based:
- RdfXmlSyntax ("RDF/XML syntax") - the most common
- Basic Semantic Web Language (BSWL)
- GRDDL - not really a serialization in itself but a way of mapping from non-RDF XML to RDF.
- RDFX - includes excellent support for reification (assertions about assertions)
- RPV
- Rx - a similar feel to RDF/XML
- RXR - similar to TriX
- SPOG - a dialect of the SPARQL XML results format.
- TreeTriples
- TriX - a "raw"-ish XML form
- Ideas that don't seem fully-formed (yet):
- Notation3 in XML - sketch of an idea
- Simplified Syntax for RDF (property names are not URIs??)
- XENT - sketch of an idea; Turtle/XML hybrid.
- NotationThree, which has various dialects, some of which go beyond the RDF data model (as does N3 itself):
- N3 Rules
- N3 RDF
- ShorthandRDF
- Turtle - Terse RDF Triple Language
- PieNt -- essentially an early draft of Turtle.
- N-Triples - a "raw" form; just lists of triples
- TriG
- MicroTurtle
- N-Quads
- JSON-based:
- JSON-LD - Rather than force RDF on developers, eases developers into RDF, using models they're already familiar with deploying.
- RDF/JSON
- RDF PHP - same idea, but PHP code rather than JSON.
- Rdfj
- jsonGRDDL - analogous to XML's GRDDL
- Dataset Transformations - Uses json to navigate the contents of html and outputs the result as RDF/XML
- JSON+RDF - a more in-depth look at the state of RDF in JSON.
- RDF/POST - serialization on top of application/x-www-form-urlencoded (previous URL and history)
- HTML embedded:
- eRDF
- RDFa ("XHTML+RDFa"), plus other RDFa host languages:
- SVG 1.2 Tiny
- DataRSS (RDFa in Atom)
- HTML+RDFa
- poshRDF
- N3inHTML
- hTurtle
- Microdata - an offshoot of the HTML5 spec
- RDF as S-expressions
- Uniform Resource Framework (URF) - a superset of RDF.
Comparison
(This doesn't need to be quite as comprehensive.)
Syntax | Basis | Named Graphs | Rules | Status |
RDF/XML | XML | no | no | W3C Rec |
TriX | XML | yes | no | proposal |
SPOG | XML, SPARQL Results | yes | no | SPARQL result format is a W3C Rec |
Notation3 | - | yes | yes | W3C Team Submission |
Turtle | Notation3 | no | no | W3C Team Submission |
N-Triples | Notation3 | no | no | W3C Rec (sort of) |
TriG | Notation3 | yes | no | proposal |
RDF/JSON | JSON | no | no | proposal on Talis wiki |
RDF/POST | HTTP | no | no | proposal |
eRDF | (X)HTML | no | no | proposal on Talis wiki |
XHTML+RDFa | XHTML | no, but proposed | no | W3C Rec |
Microdata | (X)HTML | no | no | W3C WD |
Limited Syntaxes
Some serializations are only capable of representing a subset of the RDF data model.
- RDF/XML requires property URIs to be encoded as XML QNames. Some URIs cannot be abbreviated this way. In practice, vocabulary designers tend to take this into account, so it's not much of a problem.
- Microdata cannot represent datatypes for literals, and cannot handle cyclical relationships between blank nodes.
- BSWL doesn't support blank nodes.
- Certain unicode control characters are forbidden by XML, even when escaped as numeric character references. Unless an XML-based RDF serialisation provides an additional escaping mechanism, literals containing these characters cannot be serialised.