[uf-discuss] hCard names - n vs. fn

Ciaran McNulty mail at ciaranmcnulty.com
Thu Apr 26 03:22:44 PDT 2007


On 4/22/07, Andy Mabbett <andy at pigsonthewing.org.uk> wrote:
> I'm not clear on the relationship between "n" and "fn " in hCard. I have
> some markup:
>
>         <TD class="n">
>           <SPAN class="honorific-prefix">The Rt Hon</SPAN>&nbsp;
>           &nbsp;
>           <SPAN class="fn">Tony Blair</SPAN>
>           &nbsp;
>           <SPAN class="honorific-suffix">MP</SPAN>
>         </TD>
>
> Operator gives:
>
>         fn=Tony Blair
>         object n {
>           object honorific-prefix {
>                 0=The Rt Hon
>           }
>           object honorific-suffix {
>                 0=MP
>           }
>
> Which is right, and is the mark-up valid?

Operator is correct in this instance.  The markup is valid in the
sense there's nothing wrong according to the spec, but it's probably
not conveying the meaning you hope.

'fn' in your example is clearly "Tony Blair"

A parser will find the 'n' and then find its sub properties
'honorific-prefix' and 'honorific-suffix' but not find any other
sub-properties such as 'given-name' because they are not present.

What may be causing confusion on this issue are the implied-n
optimisation rules [1].  It's important to note that they only come
into effect when n is not present.

On a side-note, the issue of what to do with user-entered names where
one isn't sure of the formatting is one I've also had issues with and
could do with some attention - for now hCard is only going to be
useful in applications where the author has the users' names split
into the relevant fields and for me it's a major stumbling block.

At the moment, by omitting n, the author is making an assertion about
the formatting of the fn, i.e. the author is effectively saying 'I do
not need to specify n subproperties because fn is in one of the
standard formats'.

It's not correct behaviour to wrap arbitrary user-entered names in fn
and assume that parsers will work it all out.

One possible solution, which I've experimented with, is to use:

<span class="fn n">
  <span class="nickname">$user_entered_name</span>
</span>

Then whatever the user has entered as their login becomes their full
name and nickname, and the other vCard fields are effectively blank.

Actually <span class="fn">$foo</span> where $foo is one word already
has this optimisation [2]

-Ciaran McNulty

[1] http://microformats.org/wiki/hcard#Implied_.22n.22_Optimization
[2] http://microformats.org/wiki/hcard#Implied_.22nickname.22_Optimization


More information about the microformats-discuss mailing list