Re: Telecon Agenda - 28th January 2010, 1600 UTC

On Wed, 2010-01-27 at 17:13 +0000, Toby Inkster wrote:
> Copied and pasted from my scratchpad (as I was/am looking at producing
> an HTML+Microdata to XHTML+RDFa convertion tool)... 

This code manages to do a pretty complete mapping from Microdata to RDFa
without changing the page layout (it needs to add additional empty
<span> elements occasionally):

http://goddamn.co.uk/viewvc/perlmods/HTML-HTML5-Microdata-ToRDFa/lib/HTML/HTML5/Microdata/ToRDFa.pm

Limitations:

- If the input page uses a mixture of Microdata and RDFa, the output
will probably be broken.

- It only looks at mapping Microdata's item* attributes. The Microdata
spec also (or at least used to also - not looked recently) provides
mappings for some other HTML attributes and elements to RDF (e.g. <meta
name>; <blockquote cite>; <title>; etc), but this code ignores all that.

- Where itemprop, itemscope and itemtype are all on the same element, it
needs to add an extra <span> element to the output to avoid losing the
rdf:type.

- RDFa doesn't have a construct similar to itemref. When the converter
finds an itemref it does some special magic to figure out what triples
would have been generated by following the itemref attribute's
references; and adds them in as extra <span> elements too.

It is probably not rock solid, but seems to get the majority of cases
right. I'm sure there are ways to trick it though.

I've not seen any microdata "in the wild" that it fails on. Though, to
be fair, I've not seen any microdata in the wild that it succeeds on
either. ;-)

Right now it's completely lacking in documentation, but once I've typed
some docs up, I'll upload it to CPAN.

-- 
Toby A Inkster
<mailto:mail@tobyinkster.co.uk>
<http://tobyinkster.co.uk>

Received on Friday, 29 January 2010 17:25:39 UTC