Question

I started digging into RDFa recently and try to spice my website with semantic information. The site offers services, events, a blog and may offer products in future. Happily schema.org has coarse but adequate categories for it all. But now it comes to practical questions.

All the examples have all information on a single page, which seems pretty academic to me. E.g. on my landing page is a list with upcoming events. Events have a location property. My events run at 2 different locations. I could paste the location information for each entry in and inflate my html. I'd rather link to pages, which describe the locations and hold full details. Not sure, whether this is what sameAs is for. But even then, how would it know which RDFa information on the target URL should be used as the appropriate vCard?

Similarly, my landing page has only partial company information visible. I could add a lot of <meta>, but again a reference to the contact page would be nice.

I just don't want to believe that this aspect slipped the RDF creators. Are there any best practices for redundancy reduction?

Was it helpful?

Solution

URIs! (or IRIs, e.g., in RDFa 1.1)

That’s one of the primary qualities of RDF, and it makes Linked Data possible, as coined by Tim Berners-Lee (emphasis mine):

The Semantic Web isn't just about putting data on the web. It is about making links, so that a person or machine can explore the web of data.

Like the web of hypertext, the web of data is constructed with documents on the web. However, unlike the web of hypertext, where links are relationships anchors in hypertext documents written in HTML, for data they links between arbitrary things described by RDF

From my answer to a question about the Semantic Web:

Use RDF (in the form of a serialization format of your choice) and define URIs for your entities so that you and other people can make statements about them.

So give all your "entities" an URI and use it as subject resp. object in RDF triples. Note that you may not want to use the same URI which your web pages have, as it would make it hard to distinguish between data about the web page and data about the thing represented by the web page (see my answer describing this in more detail).

So let’s say your website has these two pages:

  • http://example.com/event/42 (about the event 42, i.e., the HTML page)
  • http://example.com/location/51 (about the location 51, i.e., the HTML page)

Using the hash URI method, you could mint these URIs:

  • http://example.com/event/42#it (the event 42, i.e., the real thing)
  • http://example.com/location/51#it (the location 51, i.e., the real thing)

Now when you want to use the Schema.org vocabulary to give information about your event, you may use resource to give its URI:

<!-- on http://example.com/event/42 -->
<article resource="#it" typeof="schema:Event">
  <h1 property="schema:name">Event 42</h1>
</article>

And when you want to specify the event’s location (using Place), you could use the URI of the location:

<!-- on http://example.com/event/42 -->
<article about="#it" typeof="schema:Event">
  <h1 property="schema:name">Event 42</h1>
  <a property="schema:location" typeof="schema:Place" href="/location/51#it">Location 51</a>
</article>

And on the location page you might have something like:

<!-- on http://example.com/location/51 -->
<article about="#it" typeof="schema:Place">
  <h1 property="schema:name">Location 51</h1>
  <a property="schema:event" typeof="schema:Event" href="/event/42#it">Event 42</a>
</article>

Aggregating this data, you’ll have these triples (in Turtle):

@prefix schema: <http://schema.org/> .

<http://example.com/location/51#it> a schema:Place .
<http://example.com/location/51#it> schema:event <http://example.com/event/42#it> .
<http://example.com/location/51#it> schema:name "Location 51" .

<http://example.com/event/42#it> a schema:Event .
<http://example.com/event/42#it> schema:location <http://example.com/location/51#it> .
<http://example.com/event/42#it> schema:name "Event 42" .

EDIT: I’m not sure (and I hope it’s not the case), but maybe Schema.org expects a blank node with a url (or sameAs?) property instead, e.g.:

<article about="#it" typeof="schema:Event">
  <h1 property="schema:name">Event 42</h1>
  <div property="schema:location" typeof="schema:Place">
    <a property="schema:url" href="/location/51#it">Location 51</a>
  </div>
</article>

OTHER TIPS

Each RDF resource has identifier. Identifier is an IRI (and URL is a subset of IRIs). So, just reference locations by their identifiers.

Usually, each page describes one implicit main resource and several explicit additional ones. Take a look at RDFa 1.1 Primer. It has a lot of relevant info

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top