- From: Philip Jägenstedt <philipj@opera.com>
- Date: Thu, 21 Jan 2010 00:41:15 +0100
- To: bnowack@semsol.com, public-html@w3.org
On Tue, 19 Jan 2010 18:17:19 +0100, Benjamin Nowack <bnowack@semsol.com> wrote: > > Hi, > > I'm working on a Microdata parser as part of an RDF toolkit. One thing > I've implemented but that isn't directly stated in the draft is the > generation of property URIs in the context of the itemtype. The spec > mentions that plain properties are to be used "within the context of > the types for which they are intended". And RDF vocabularies follow > the {namespace}/{type|prop} or {namespace}#{type|prop} pattern. So, > I made my parser extract the following RDF triples: > > _:bnode a <http://xmlns.com/foaf/0.1/Person> . > _:bnode <http://xmlns.com/foaf/0.1/name> "Alec Tronnick" . > _:bnode <http://xmlns.com/foaf/0.1/img> <mypic.jpg> . > > from the Microdata snippet: > > <div itemscope="" itemtype="http://xmlns.com/foaf/0.1/Person"> > My name is <span itemprop="name">Alec Tronnick</span> > <img itemprop="img" src="mypic.jpg" alt="" /> > </div> > > as "name" and "img" are supposed to be applicable to the "Person" > type from the FOAF vocabulary. This sort of rule leads to very > compact markup in most single-vocab use cases (even more compact > and readable than RDFa's CURIEs) and simple authoring. > > A sophisticated parser *could* GET and check the RDF vocabulary > for valid use of properties, but RDF does not have instance-level > validation, so the transparent expansion of plain property names > does not conflict with the RDF spec(trum). An author can of > course still use full URIs to mix in terms from other vocabs. If you follow the conversion algorithm at <http://dev.w3.org/html5/md/#rdf>, you'll find that your markup yields something like these triples: @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . _:n0 rdf:type <http://xmlns.com/foaf/0.1/Person> ; <http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson%23%3Aname> "Alec Tronnick" ; <http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson%23%3Aimg> <http://example.com/mypic.jpg> . <http://example.com/foo.html> <http://www.w3.org/1999/xhtml/microdata#item> _:n0 . Note especially that mypic.jpg is resolved, here I assumed the markup was from http://example.com/foo.html. To produce the triples you wanted, use this markup: <div itemscope="" itemtype="http://xmlns.com/foaf/0.1/Person"> My name is <span itemprop="http://xmlns.com/foaf/0.1/name">Alec Tronnick</span> <img itemprop="http://xmlns.com/foaf/0.1/img" src="mypic.jpg" alt="" /> </div> As you can see, microdata has no prefix notation. To save yourself some typing, use this: <div itemscope itemtype="http://microformats.org/profile/hcard"> My name is <span itemprop="fn">Alec Tronnick</span> <img itemprop="photo" src="mypic.jpg" alt=""> </div> If you actually wanted to use FOAF or care very much about the exact triples, then the OWL needed to map the above to vCard RDF shouldn't be very tricky, and I assume the relationship between FOAF and that is already pretty clear. -- Philip Jägenstedt Core Developer Opera Software
Received on Wednesday, 20 January 2010 23:41:49 UTC