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

3

6

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 :)

Ganister answered 1/6, 2013 at 14:15 Comment(0)
D
2

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.

Doubletongue answered 17/9, 2013 at 15:15 Comment(0)
D
1

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.

Dragonfly answered 5/6, 2013 at 5:11 Comment(0)
S
1

Stephan's advice is in general conformance with RDF Lite 1.1, which does not include @rel or @about for precisely these reasons.

Another good rule of thumb is to not try to include markup of more than one entity on a given element, which was often an example of specifying an images license.

@property and @rel are very similar to each others, but served different purposes in RDFa 1.0, but this was confusing, even for experts. (Formerly, @rel was used for specifying objects which are other nodes, and @property was used for specifying literal values. While there are some remaining differences, but sticking to non-clever markup, you can do everything with @property that you could do with @rel.

Similarly, @about can be avoided to just use @resource. The difference is that @about sets the current subject and @resource the current object, but for child nodes the parent object (taken from the parent's current object becomes the current subject. There were another minor differences concerning the presence of @typeof, but if you only use @resource, it pretty much does what you want.

To summarize the best practices from RDFa Lite 1.1 you can also check out the RDFa 1.1 Primer:

  • stick to @vocab, @prefix, @property, @resource, and @typeof
  • avoid making more than one statement in a given element
Strachey answered 7/6, 2013 at 23:22 Comment(2)
Thanks for the info but: "While there are some remaining differences..." & "There were another minor differences..."; could you please elaborate?Ganister
Main difference is the behavior of \@property with or without \@rel. If there is no \@rel, \@property can be used for a resource or a literal. In 1.0 \@property only works on a literal. There are also differences if \@about is present and @typeof, mainly to meet developer expectations. Some of the differences are recorded in the spec. The main advice is to avoid mixing markup on a single element. See RDFa Lite for suggested patterns.Strachey

© 2022 - 2024 — McMap. All rights reserved.