RDFaLiteWithProperty

From RDFa Working Group Wiki
Revision as of 22:04, 31 October 2011 by Gkellogg (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

RDFa 1.1 Lite [1] has been proposed as an authoring profile and general recommendation for users to easily add RDFa to HTML pages while avoiding some of the more complex rules that tend to confuse non-expert users. To summarize, RDFa 1.1 Lite makes use of just @vocab, @typeof, @property, @rel, @about, and @prefix.

However, recent communications on the Vocabs mailing list [2] indicate that the use of both @rel and @property is still confusing, and there's a real need to simplify further and avoid the use of @rel altogether. This has been problematic for the RDF Web Apps WG, as it would seem to introduce backwards-compatibility issues with RDFa 1.0, where the two have very different semantics.

This proposal seeks to avoid the compatibility issues by defining special processing rules for @property in the context of HTML+RDFa, which do not lead to backwards compatibility issues, as there is no HTML+RDFa profile for RDFa 1.0.

Concept

The basic idea is to adopt some of the Microdata @itemprop rules for specific HTML element tags to get @rel-like behavior for @property. This does not replace @rel, but makes it's use unnecessary for non-expert usage.

Microdata describes how to retrieve a property value [3]. The Microdata to RDF draft uses essentially the same, but with some additional detail for creating RDF [4]. Basically, elements that have an attribute with a URI content model (@src, @href or @data) use that value to create a URI Reference, and otherwise a literal is generated. Otherwise, @property acts as now defined in RDFa Core 1.1.

Chaining

RDFa already provides a means of chaining objects together using the @rel property. However, it has proven to be confusing to some, and is a common source of errors [5].

An alternative way to do chaining could be done using @property. If @property were used in an element that also had either or both @about or @typeof, but not @rel, @content or @datatype, it would become a reference (URI or BNode) to a new object defined at that element scope, identically to @itemprop in the same element as @itemscope. Chaining is not done implicitly, as with @rel, but requires the use of either or both of @about or @typeof in the same element as the @property, and evaluation of @property is in the context of the parent subject and the newly created item becomes an object reference, as contrast with @rel, where the new subject is used in the subject space, and @rel is evaluated by looking at appropriate child elements or at an @resource property.

Note, the HTML WG would have to allow meta and link tags in the body if used with a @property. Or, the HTML WG could just make it simpler and remove restrictions on meta and link in the body altogether, although they would have no purpose but to express metadata. It would allow it's use for other specs, such as Microformats, though.

Examples

A schema:Event might be marked up as follows:

<div vocab="http://schema.org/" typeof="Event">
  <a property="url" href="nba-miami-philidelphia-game3.html">
  NBA Eastern Conference First Round Playoff Tickets:
  Miami Heat at Philadelphia 76ers - Game 3 (Home Game 1)
  </a>

  <span property="startDate">2011-04-21T20:00</span>

  <div property="location" typeof="Place">
    <a property="url" href="wells-fargo-center.html">
    Wells Fargo Center
    </a>
    <div property="address" typeof="PostalAddress">
      <span property="addressLocality">Philadelphia</span>,
      <span property="addressRegion">PA</span>
    </div>
  </div>

  <div property="offers" typeof="AggregateOffer">
    Priced from: <span property="lowPrice">$35</span>
    <span property="offerCount">1,938</span> tickets left
  </div>
</div>

In this example, note that the anchor use of @property="url" creates an IRI ref, and not a literal. To create a literal for the content of the a tag, would involve using span elements with their own properties. As @property in itself does not create a new subject, the content of the a tag shares the same subject.

For example:

<div vocab="http://schema.org/" typeof="Event">
  <a property="url" href="nba-miami-philidelphia-game3.html">
    <span property="description">
      NBA Eastern Conference First Round Playoff Tickets:
      Miami Heat at Philadelphia 76ers - Game 3 (Home Game 1)
    </span>
  </a>
</div>

would create the following Turtle:

[ a schema:Event;
  schema:url <nba-miami-philidelphia-game3.html>;
  schema:description """
      NBA Eastern Conference First Round Playoff Tickets:
      Miami Heat at Philadelphia 76ers - Game 3 (Home Game 1)
    """ ] .

Also, the Event is related to a Place using a schema:location predicate.

<div vocab="http://schema.org/" typeof="Event">
  <div property="offers" typeof="AggregateOffer">
    Priced from: <span property="lowPrice">$35</span>
    <span property="offerCount">1,938</span> tickets left
  </div>
</div>

would create the following Turtle:

[ a schema:Event;
  schema:offers [
    a schema:AggregateOffer;
    schema:lowPrice "$35";
    schema:offerCount "1,938"
  ]
] .

Note that schema:offers is a property of schema:Event, not schema:AggregateOffer, as it would be if @rel were used instead.

Processing

The HTML+RDFa 1.1 spec [6] section 3.1 Additional RDFa Processing Rules would be updated with further modifications to the RDFa Core 1.1 processing steps:

To support IRI reference and implicit typed literal generation:

  • Step 5 is updated as follows:
  • If the current element contains no @rel or @rev attribute, then then the next stop is to establish a value for new subject. Any of the attributes that can carry a resource can set new subject;
    • new subject is set to the IRI obtained from the first match from the following rules:
      • by using the IRI from @about, if present, obtained according to the section on CURIE and IRI Processing;
      • otherwise, by using the IRI from @resource, if present, obtained according to the section on CURIE and IRI Processing, unless current element has a @property attribute;
      • otherwise, by using the URI from @href, if present, obtained according to the section on CURIE and IRI Processing, unless current element has a @property attribute.
      • otherwise, by using the URI from @src, if present, obtained according to the section on CURIE and IRI Processing, unless current element has a @property attribute.
    • If no IRI is provided by a resource attribute, then the first match from the following rules will apply:
      • if the element is the root element of the document, then act as if there is an empty @about present, and process it according to the rule for @about, above;
      • if @typeof is present, then new subject is set to be a newly created bnode.
      • otherwise, if parent object is present, new subject is set to the value of parent object. Additionally, if @property is not present then the skip element flag is set to 'true';
  • Step 11 is updated as follows:
  • Predicates for the current object literal can be set by using @property. If present, one or more IRIs are obtained according to the section on CURIE and IRI Processing, and then the actual literal value is obtained as follows:
    • As a typed literal if @datatype is present ...
    • otherwise, as an XML literal if @datatype is present ...
    • otherwise, as a plain literal using the value of @content if @content is present
    • otherwise, as a plain literal without language component, using the value of @value if @value is present (HTML+RDFa only)
    • otherwise, as a URI reference by resolving the first value of the element's @href, @src, @resource or @data attributes if any are present,
    • otherwise, as a value returned from #HTML Element Value, if not null
    • otherwise, as a plain literal ...

Additionally, to support chaining aspects of @property:

  • Step 11 is updated as follows:
  • Predicates for the current object literal can be set by using @property. If present, one or more IRIs are obtained according to the section on CURIE and IRI Processing.
  • If Step 5 resulted in a new subject due to the presence in current element of @about or @typeof, without @rel, @content or @datatype, and one or more IRIs are obtained from @property according to the section on CURIE and IRI Processing, do not create a literal, instead, generate the following triple for each IRI obtained from @property (also include @inlist processing):
    subject: parent subject
    predicate: full IRI
    object: new subject
  • Otherwise, the actual literal value is obtained as follows:
    • otherwise, as an XML literal if @datatype is present ...
    • otherwise, as a plain literal using the value of @content if @content is present
    • otherwise, as a URI reference by resolving the first value of the element's @href, @src of @data attributes if any are present,
    • otherwise, as a value returned from #HTML Element Value, if not null
    • otherwise, as a plain literal ...
  • If not null, the current object literal is then used with each predicate as follows ...