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

I am currently teaching RDFa Core 1.1 after successfully learning RDFa Lite quite easily. Right, 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 expressions than spec :)

+4
source share
3 answers

I personally would recommend ignoring / avoiding the use of rel and that you don’t really need to write RDFa if you follow the rule of thumb that you should not try to be too smart by typing as many attributes as possible into a given HTML element. There are reasons for backward compatibility. Other attributes from 1.1 are worth exploring: content and data type.

+2
source

Stephan's advice generally follows RDF Lite 1.1 , which does not include @rel or @about precisely these reasons.

Another good rule of thumb is not to try to include markup of more than one object in a given element, which is often an example of setting an image license.

@property and @rel very similar to each other, but different goals were used in RDFa 1.0, but it was difficult, even for experts. (Previously, @rel used to specify objects that are other nodes, and @property used to indicate letter values. Although there are some remaining differences, when using fuzzy markup, you can do everything with @property which you can do with @rel .

Similarly, @about can be avoided simply by using @resource . The difference is that @about sets the current object and @resource current object, but for child nodes the parent object (taken from the parent current object becomes the current subject . There were still some slight differences regarding the presence of @typeof , but if you use only @resource He pretty much does what you want.

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

  • stick with @vocab , @prefix , @property , @resource and @typeof
  • avoid creating more than one statement in this element
+2
source

property vs. rel :

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

The difference is where they get their object from. A bit simplified rules for property are: Object taken ...

  • from a valid content attribute or, if this is not in the tag,
  • (if the tag :) does not have the datatype attr attribute) from a valid resource attribute or, if it is not in the tag,
  • (if the tag :) does not have the datatype attr attribute) from the actual href attribute, or if it is not in the tag,
  • (if datatype attr is not present in the tag) from a valid src attribute, or if it is not in the tag,
  • from the internal content of the element triggered by the tag.

A bit simplified, rel differs in two aspects:

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

about vs resource :

about is an attribute pointing to the subject of a triple. The rules for resource more complex: it can point to an object or object, and the chain also plays here.

IMHO, the chain is the most complex and confusing part of RDFa (and does not give you more than syntactic sugar). I would avoid the chain. This can be avoided by avoiding the rel , rev , resource and typeof attributes, which at the same time leads to some simplification. Thus, I use only the following attributes:

  • about for an object
  • property for predicate
  • content or href or src (or the internal content of the element) for the object, following the rules above
  • lang for a language tag for object literals, for example. lang="en"
  • datatype for data type tag for object literals
  • prefix (but only once per document) so that I can shorten URLs by prefix, for example. property="dc:creator"
  • vocab (rarely and not more than once in a document), so that I can implicitly shorten URLs, for example. property="creator" .

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

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

+2
source

Source: https://habr.com/ru/post/1483944/


All Articles