In short. RDFa preserves list order by collecting inlist values into an RDF first and rest chain in document order.
Definition: RDFa preserves the order of values by placing each value marked with
inlistinto an RDF list for the same predicate and subject. The list follows the values' document order, while the value of theinlistattribute itself is ignored.
Key facts
- RDF graphs are sets of subject-predicate-object triples. RDF 1.1 Concepts says that different ordering of statements is not significant for the meaning of an RDF graph. W3C's RDF 1.1 Concepts and Abstract Syntax describes this data model.
- RDFa Core defines
inlistas an attribute that adds the object from the same element'srelorpropertyattribute to the list for that predicate. Its value is ignored, and its presence creates a list when needed. The W3C RDFa Core specification defines the attribute. - The RDFa specification states that list order is determined by document order. The generated list uses
rdf:first,rdf:rest, andrdf:nilto represent its members and its end. The W3C list-generation section gives the processing details.
How does inlist preserve order?
Without a list, several values for one predicate are separate triples in an RDF graph. The RDF 1.1 data model treats that graph as a set, so the order in which those triples appear in a document or serialization does not carry meaning. RDFa adds an ordered structure when the inlist attribute is present: the processor adds each current property value to the list mapped to the predicate, in the sequence in which it processes the document.
The attribute belongs on the element that generates the value. Its value can be empty because the specification makes presence significant and says the value is ignored. The predicate can come from property; RDFa also defines list handling for rel when inlist is present.
The specification's example uses this pattern:
<p prefix="bibo: http://purl.org/ontology/bibo/ dc: http://purl.org/dc/terms/" typeof="bibo:Chapter">
<a inlist="" property="dc:creator" href="http://ben.adida.net/#me">Ben Adida</a>,
<a inlist="" property="dc:creator" href="http://twitter.com/markbirbeck">Mark Birbeck</a>, and
<a inlist="" property="dc:creator" href="http://www.ivan-herman.net/foaf#me">Ivan Herman</a>.
</p>
What RDF structure does a processor create?
RDFa Core first keeps the values in a list mapping. When list generation finishes, it creates a blank node for each item. Each blank node receives an rdf:first triple for its value and an rdf:rest triple pointing to the next blank node. The last rdf:rest points to rdf:nil, and the common subject and predicate point to the first blank node. This linked structure carries the sequence independently of the order of the serialized triples.
The specification shows the resulting collection in Turtle notation:
@prefix dc: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
dc:creator (
<http://ben.adida.net/#me>
"Mark Birbeck"
<http://www.ivan-herman.net/foaf#me>
) .
The list-generation rules also define an empty list case: when the list has zero items, the processor uses rdf:nil as the object of the common subject and predicate.
Which values can an RDFa list contain?
An RDFa list can contain IRIs and literals. An IRI can come from an element such as a with href, or from a resource attribute; visible text can supply a literal property value. The RDFa example combines the IRI for Ben Adida, the literal Mark Birbeck, and the IRI for Ivan Herman in one dc:creator list.
RDFa also permits rel with inlist for resource relationships. The specification says that this form leads to the same triples as the corresponding property form when the subject, predicate, and object are the same. A nested rel value can therefore contribute resource items to the list while the document retains its ordinary link structure.
How should you check the markup?
Check that every value intended for one ordered collection uses the same predicate and that each value-generating element has inlist present. Then compare the intended sequence with the document order, because RDFa defines that order from the document. Finally, inspect the extracted RDF for an rdf:first and rdf:rest chain ending in rdf:nil, with the page's subject and predicate pointing to the chain's first node.
For an explicitly empty collection, the RDFa specification gives this form:
<span rel="prop" resource="rdf:nil"></span>
Related terms
FAQ
Does the value of inlist matter?
No. RDFa Core says that the value is ignored. Presence of the attribute is the signal that the generated object belongs in the list.
Does document order alone make repeated RDF values ordered?
No. RDF 1.1 Concepts describes RDF graphs as sets of triples and says that different ordering of statements is not significant for their meaning. The inlist attribute supplies the RDF list structure that carries the sequence.
Can one RDFa list mix links and text?
Yes. RDFa Core's example places IRIs and a literal in the same list, preserving their document order.
Sources
- W3C, "RDFa Core 1.1 - Third Edition", 17 March 2015
- W3C, "RDF 1.1 Concepts and Abstract Syntax", 25 February 2014
Check how a page reads to answer engines. Open the GEO score analyzer