Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In RDFa, difference between property="" & rel="", and resource="" & about=""?

I am currently teaching myself RDFa Core 1.1 after successfully learning RDFa Lite rather easily. Straight to the point, I can't understand two things: the difference between property and rel, and the difference between resource and about.

Please explain to me in simpler terms than the spec :)

like image 881
Sketch R Avatar asked Jun 01 '13 14:06

Sketch R


2 Answers

property vs. rel:

Both attributes indicate a predicate of a triple, e.g. rel="http://purl.org/dc/terms/creator, which is the predicate ... has as a creator: ....

The difference is, from where they take their object. Slightly simplified, the rules for property are: The object is taken ...

  • from a valid content attribute or, if this is not present in the tag,
  • (if no datatype attr is present in the tag:) from a valid resource attribute or, if this is not present in the tag,
  • (if no datatype attr is present in the tag:) from a valid href attribute or, if this is not present in the tag,
  • (if no datatype attr is present in the tag:) from a valid src attribute or, if this is not present in the tag,
  • from the inner content of the element started by the tag.

Slightly simplified, rel differs in two aspects:

  • It takes its object only from a resource or a href or a src attribute.
  • It takes its object not only from an attribute of the same tag, but may also take it from descendant tags. The whole mechanism is called "chaining": "This is the main difference between @property and @rel: the latter induces chaining, whereas the former, usually, does not." 1 Usually, but property can induce chaining if used with typeof (cf. 2).

about vs resource:

about is the attribute to indicate the subject of a triple. The rules for resource are more complicated: It may indicate a subject or an object, and chaining plays a role here, too.

IMHO, chaining is the most complicated and confusing part of RDFa (and does not give you more than syntactic sugar). I would avoid chaining. This is possible by avoiding the attributes rel, rev, resource and typeof, which brings some further simplification at the same time. Thus, I use only the following attributes:

  • about for the subject
  • property for the predicate
  • content or href or src (or the inner content of the element) for the object, following the rules outlined above
  • lang for a language tag for object literals, e.g. lang="en"
  • datatype for a datatype tag for object literals
  • prefix (but only once in a document), so that I can abbreviate URLs by prefixing, e.g. property="dc:creator"
  • vocab (rarely and at the most once in a document), so that I can abbreviate URLs implicitly, e.g. property="creator".

(And I use the tag <base href="..."> to indicate the URL base value of the document.)

This is a strict, safe, easy-to-use and easy-to-parse subset of RDFa and allows to express any triple you want.

like image 108
Stefan Avatar answered Sep 20 '22 12:09

Stefan


I would personally recommend to ignore / avoid using rel and about, they are not really necessary to write RDFa if you follow the rule of thumb that you should not try to be too smart by stuffing as many attributes as possible in a given HTML element. There are around for backward compatibility reasons. The other attributes from 1.1 are worth learning though: content and datatype.

like image 29
scor Avatar answered Sep 17 '22 12:09

scor