[uf-discuss] include pattern proxy

Scott Reynen scott at randomchaos.com
Wed Jun 7 18:54:40 PDT 2006


On Jun 7, 2006, at 9:43 AM, Tantek Çelik wrote:

> Those of you who have written parsers out there (Scott Reynen,  
> Assaf Arkin,
> Tails/Flocktails folks, Reevoo, etc.), if you could please take a  
> look at
> modifying your code to implement object-include support for the  
> microformats
> you parse (e.g. hCard, hCalendar, hReview), it would be good to  
> know if the
> adding support for the include-pattern is:
>
> 1. easy
> 2. possible, but a bit of work
> 3. possible, but challenging/hard
> 4. impossible

1. easy

I haven't yet included this in either of my parsers, but here's a  
proxy you can use to do inclusion for you:

http://microformat.makedatamakesense.com/object_includer/

Here is the relevant portion of code in PHP 5:

----
$objects = $dom->getElementsByTagName( 'object' );
		
for ( $i = 0; $i < $objects->length; $i++ )
{

	$object = $objects->item( $i );
	$classes = explode( ' ' , $object->getAttribute( 'class' ) );
	if ( in_array( 'include' , $classes ) )
	{

		$data = $object->getAttribute( 'data' );
		if ( $data[0] == '#' )
		{
		
			$data_node = $dom->getElementById( substr( $data , 1 ) );
			
			if ( $data_node )
			{
			
				$object->parentNode->replaceChild(
					$data_node->cloneNode( true ) , $object
				);

			} // if
		
		} // if
	
	} // if

} // for
----

On Jun 7, 2006, at 11:57 AM, Michael Leikam wrote:

> Since the X2V parser is not producing
> what I'd hoped, I'd like some feedback on how the markup
> could be improved.

I don't think you should be changing your code to suit a parser's  
divergence from the current spec.  Here's a ridiculous URL of your  
data in vCard, after piping the document through two proxies:

<http://suda.co.uk/projects/X2V/get-vcard.php?uri=http%3A%2F% 
2Fmicroformat.makedatamakesense.com%2Fobject_includer%2F%3Furl%3Dhttp% 
253A%252F%252Fdaf.csulb.edu%252Forganization%252Ftelecom_hcard- 
test.html>

It turns out the emails aren't being parsed even after the inclusion  
is done with the root referenced node.  I believe this is because  
you're putting them in <area> tags, and the hcard spec only allows  
them to be put in <a> tags:

'Similarly, EMAIL in vCard becomes <a class="email"  
href="mailto:...">...</a>'

http://microformats.org/wiki/hcard#More_Semantic_Equivalents

Peace,
Scott


More information about the microformats-discuss mailing list