This specification defines a DOM API for accessing RDFa data contained in a structured document, such as SVG, XHTML or HTML. The RDFa DOM API can be used to extract a specific RDF triple, or set of triples, based on a subject query.
RDFa [[!RDFA-SYNTAX]] has seen substantial growth since it became an official W3C Recommendation in October 2008. It has seen wide adoption among search companies, e-commerce sites, governments, and content management systems. There are numerous interoperable implementations and growth is expected to continue to rise.
In an effort to ensure that browser-based applications are able to fully utilize RDFa, this specification outlines a set of routines that are capable of extracting RDFa from web pages for use in Javascript applications, as well as browser extensions. The RDFa DOM API allows a programmer to query the RDF model expressed by a document and then make programmatic decisions based on the semantic data embedded in the page.
The RDFa DOM API strives to be a simple set of calls that a developer may use to retrieve triples contained in the document.
This section describes the set of additional methods that must be defined
on the standard Document
interface as defined in
[[!DOM-LEVEL-2-CORE]].
The type
parameter may be null or an empty string. In both cases,
all subjects from the page should be returned in the array of
Triple
objects.
The getTriplesByType
method allows both full URI specification
as well as short-hand specification. A type
may be given by
specifying a complete URI, for example
http://xmlns.com/foaf/0.1/Person
, or a short-hand
DOMString
such as Person
.
To perform a match, a direct string comparison is performed. If the string
comparison fails, the given type
is checked against a subject's
type starting at the last character in each string and moving backwards.
Each character is compared until there is a character mis-match, or all of
the characters in the type
string are exhausted. If all of the
characters in the type
string are exhausted and there were no
character mis-matches, the subject's type must be considered a match.
This section will contain best practices on storing and retrieving triples on a page.
This document has been prepared with the help of the following people (in alphabetical order):