Representing root class names

Root class names map neatly to rdf:type. In Notation3, this is represented with the shorthand a.

<divclass="h-card">Tom Morris</div>

_:bnode01 a uf:h-card .

This is compatible with the RDF specification, but differs from RDF best practice. As with Java and most programming languages, in RDF, it is customary to capitalize class names.

Representing properties

Once we have inferred the class name, we need simply declare the properties.

For each p- prefixed property, an RDF statement should be produced with the subject being that of the microformats2 object, the property being the namespaced microformats property, and the object being either a plain literal or a language literal containing the string representation of the object (see language section below). This should be equal to the string value in the JSON output.

Multiple properties

If there are multiple instances of a property, this should result in multiple statements using the same property name.

This example hCard contains two category properties and two URL properties:

<divclass="h-card"><imgclass="u-photo"alt="photo of Mitchell"src="https://webfwd.org/content/about-experts/300.mitchellbaker/mentor_mbaker.jpg"/><aclass="p-name u-url"href="http://blog.lizardwrangler.com/">Mitchell Baker</a>
(<aclass="u-url"href="https://twitter.com/MitchellBaker">@MitchellBaker</a>)
<spanclass="p-org">Mozilla Foundation</span><pclass="p-note">
Mitchell is responsible for setting the direction and scope of the Mozilla Foundation and its activities.
</p><spanclass="p-category">Strategy</span><spanclass="p-category">Leadership</span></div>

Language

Typed literals contain a datatype annotation, language literals contain a language annotation (the same ISO country codes as is used in HTML's lang attribute and XML's xml:lang attribute).

Processors should work out the language tag (if any) of the elements containing microformat properties (using the latest RDFa specification) and emit language-tagged literals for p- prefixed properties. If no language tag is set in the HTML, emit plain literals for all p- prefixed properties.

It is arguable that one may wish to then omit the p-name property from RDF representations of Microformats2 objects. The minor cost of extra duplication is outweighed by ensuring faithful representation and the ability to bidirectionally convert from RDF representations and JSON representations of Microformats2 objects.

Representing nested microformats

This is easy. Each new object becomes a new RDF resource, and there is a relationship going from the parent object to the child object.