[microformats-discuss] A 10 line script to identify and process any microformat

Alf Eaton alf at hubmed.org
Fri Jul 29 05:23:47 PDT 2005


On 29 Jul 2005, at 14:10, Bud Gibson wrote:

> Thanks for the recommendation regarding script requests.  Aside  
> from some (in my opinion) minor corner cases, I agree that GM  
> cracks the identification issue nicely, and I would like to see  
> more people adopt the approaches shown in my script and Alf's more  
> developed examples (there's a great one here: http:// 
> hublog.hubmed.org/files/hreviewextractor.user.js that does  
> essentially the same thing for hReview that Hotelling does for  
> hCard but with a lot less code devoted to identification).

That script's a bit old and doesn't do the extra className checking  
that I recommended yesterday. Also it's a different approach to  
George Hotelling's script as it picks out the microformat fragment  
and works on that, rather than passing the whole page off to an  
external processor. What you end up with is just the raw XML, rather  
than a processed hCard -> ICS conversion. However...

> As for needing to parse the microformat into data structures, the  
> proof is in the pudding there.  You could just continue to use  
> XPath, and that might even be desirable given the semistructured  
> nature of microformats.  There are also some times where you may be  
> better off doing the heavy processing on a server.  All of these  
> topics might be better discussed in another forum, I just raise them.

I have a Greasemonkey script at the moment which identifies a  
microcontent fragment, loads in an external XSLT file, processes the  
fragment and can then insert it back into the document/put it in a  
data URI, do whatever you want with it.  At the moment I'm trying to  
figure out how to make it not request the XSLT file from my server on  
every page view that contains a fragment, but it depends on  
Greasemonkey variable scoping which is changing too much this week.

The main point then is - what do you want to do with this data once  
you have extracted and processed it? POSTing it to a remote server is  
one idea, but then you could do the processing on the server anyway.  
I haven't really though of anything useful yet :-)

alf.


More information about the microformats-discuss mailing list