[uf-discuss] Standardized Representation of Microformats in PHP/other languages

Derrick Lyndon Pallas derrick at pallas.us
Thu Apr 3 07:20:19 PST 2008

Ciaran McNulty wrote:
> As a tangential note from the discussion about a standardised JSON
> format, it would be useful to be able to represent uF data as
> datastructures in other programming languages.
There seems to be a lot of confusion here about the differences between 
syntax, structure, and semantics. What is the difference between

    {"given-name": "John", "family-name": "Doe"}
    {"family-name": "Doe","given-name": "John"}

There is a potential structural difference (e.g., in PHP, where 
associative arrays have order) but the syntax is the same and (depending 
on the application) the semantics are probably the same. What's the 
difference between

    {"given-name": "John", "family-name": "Doe"}
    { "given-name" => "John", "family-name" => "Doe" }

There is only a syntactic difference, in that the former is Javascript 
and the latter is Ruby. Both the structure and the semantics are 
identical, that is: create a mapping such that the string "given-name" 
associates with "John", and the string "family-name" associates with "Doe".

The point is that different representations can have the same structure 
and semantics. In this case, it seems like a mistake to talk about a 
representational mapping. As far as I understood, microformats is 
primarily concerned about adding semantic value specifically to HTML. 
This is done with well-defined structure that translates (as defined by 
microformats) into the syntax of HTML.

So then, what is the difference between

    {"given-name": "John", "family-name": "Doe"}
    <span class="given-name">John</span><span class="family-name">Doe</span>

Primarily a syntactic one. Structurally they are the same and 
semantically they are both hCard fragments. A more fundamental 
difference, however, is that the latter is the primary syntax; 
conversion from HTML to JSON will be lossy. Furthermore, the semantics 
are now twice filtered: the converter has to be as up-to-snuff on the 
currently defined classes as the consuming application itself. Finally, 
you lose many of the benefits of hypertext: the include pattern no 
longer works, URIs become strings, and it isn't clear how embedded 
microformats should be handled.

The only real way to share microformatted information is to pass it 
around in an HTML container, directly or as a URL. Defining a generic 
conversion is a mistake. Instead, we should focus on semantics and let 
applications define their own internal representations.


More information about the microformats-discuss mailing list