HTML and CSS Reference
The Resource Description Framework technology is important from the standardization point of view for many
reasons. First, the basic data model of RDF is a standard graph. Second, the naming system applies standard URLs.
The data retrieval and composition mechanisms used by RDF are also standard technologies.
RDF can be provided in a variety of syntaxes/serialization formats, for example, RDF XML serialization
(RDF/XML), RDFa, Turtle, Notation3, JSON-LD, N-Triples , TRiG , and TRiX . The most common ones
are described in the next sections.
RDF in XML Serialization Syntax
The recommended and most frequently used syntax for RDF applications is the XML serialization format, RDF/XML
. Although there are other notations of RDF that are easier to read and write (see the next sections), RDF/XML
provides widely accepted XML documents. However, the fundamental problem with RDF/XML is the contradiction of
representing a graph with a tree structure.
The Internet media type for RDF/XML is application/rdf+xml . The recommended file extension is .rdf .
The XML serialization of RDF provides well-formed XML documents (Chapter 1).
A person's Wikipedia page, for example, can be described in a machine-readable form in RDF/XML, as shown in
Listing 7-55. A Wikipedia Page Described in RDF/XML
RDF in N3 Syntax
Notation 3 , often abbreviated as N3 , is a shorthand non-XML serialization of RDF. It is a superset of RDF and is more
compact than the XML serialization of RDF. The grammar of N3 is defined by W3C in many formats , for example,
in Extended Backus-Naur Form ( EBNF ) 6 .
The MIME type and character encoding of N3 should be declared as text/n3; charset=utf-8 . The typical file
extension is .n3 . Tokenizing and whitespace handling are not specified in the grammar.
Base URIs to be used for the parsing of relative URIs can be set with the @base directive in the form
@base <http://example.com/overview/> .
A prefix can be associated to a namespace URI by the @prefix directive.
Several rules for string escaping are derived from Python, namely, stringliteral , stringprefix , shortstring ,
shortstringitem , longstring , longstringitem , shortstringchar , and longstringchar . Additionally, the \U extension,
also used in another RDF serialization (N-Triples), can be applied. Legal escape sequences are \newline , \\ (backslash, \ ),
\' (single quote, ' ), \" (double quote, " ), \n (ASCII Linefeed, LF), \r (ASCII Carriage Return, CR), \t (ASCII Horizontal Tab,
TAB), \uhhhh (Unicode character in BMP), and \U00hhhhhh (Unicode character in plane 1-16 notation). The escapes \a , \b ,
\f , and \v cannot be used because the corresponding characters are not allowed in RDF.
6 EBNF is a family of metasyntax notations that can be used to express context-free grammars.