HTML-Microformats

 view release on metacpan or  search on metacpan

lib/HTML/Microformats/Format/hResume.pm  view on Meta::CPAN

	my $clone = $element->cloneNode(1);	
	$self->_expand_patterns($clone);
	$self->_simple_parse($clone);
	
	$self->{'DATA'}->{'contact'} = $self->{'DATA'}->{'address'}
		unless defined $self->{'DATA'}->{'contact'};
	
	if (defined $self->{'DATA'}->{'contact'})
	{
		$self->{'id.holder'} = $self->{'DATA'}->{'contact'}->id(0, 'holder');
	}
	else
	{
		$self->{'id.holder'} = $context->make_bnode;
	}
	
#	# Create links between hCard and hCalendar events found within!
#	foreach my $prop (qw(education experience))
#	{
#		foreach my $e ( @{$self->{'DATA'}->{$prop}} )
#		{
#			foreach my $ehc ( @{$self->{'DATA'}->{$prop.'-hcard'}} )
#			{
#				my $ehcxp = $ehc->{'parent_property_node'}->getAttribute('data-cpan-html-microformats-nodepath');
#				if ($ehcxp eq $e->{'parent_property_node'}->getAttribute('data-cpan-html-microformats-nodepath'))
#				{
#					$e   -> {'associated_hcard'}   = $ehc;
#					$ehc -> {'associated_hevent'}  = $e;
#				}
#			}
#		}
#		
#		foreach my $card ( @{$self->{'DATA'}->{$prop.'-hcard'}} )
#		{
#			$card->{'id.holder'} = $self->id(0, 'holder');
#		}
#		
#		delete $self->{'DATA'}->{$prop.'-hcard'};
#	}

	$cache->set($context, $element, $class, $self)
		if defined $cache;
	
	return $self;
}

sub format_signature
{
	my $self  = shift;
	
	my $cv  = "http://purl.org/captsolo/resume-rdf/0.2/cv#";
	my $cvx = "http://ontologi.es/hresume#";

	# parsing hCards seems to do more harm than good!
	my $rv = {
		'root' => 'hresume',
		'classes' => [
			['summary',     '?'],
			['contact',     'm?',  {'embedded'=>'hCard'}],
			['address',     'tm?', {'embedded'=>'hCard'}],
			['education',   'm*',  {'embedded'=>'hEvent', 'allow-interleaved' => ['vcalendar']}], #}],, 'again-again'=>1}],
			#['education',   'm*',  {'embedded'=>'hCard',  'allow-interleaved' => ['vcalendar', 'vevent'], 'use-key'=>'education-hcard'}],
			['experience',  'm*',  {'embedded'=>'hEvent', 'allow-interleaved' => ['vcalendar']}], #}],, 'again-again'=>1}],
			#['experience',  'm*',  {'embedded'=>'hCard',  'allow-interleaved' => ['vcalendar', 'vevent'], 'use-key'=>'experience-hcard'}],
			['skill',       '*'],
			['affiliation', 'M*',  {'embedded'=>'hCard'}],
			['cite',        't',   {'use-key'=>'publication'}]
		],
		'options' => {
		},
		'rdf:type' => ["${cv}CV"] ,
		'rdf:property' => {
			'summary'     => { 'literal'  => ["${cv}cvDescription"] },
			'experience'  => { 'resource' => ["${cvx}experience"] },
			'education'   => { 'resource' => ["${cvx}education"] },
			'contact'     => { 'resource' => ["${cvx}contact"] },
			'affiliation' => { 'resource' => ["${cvx}affiliation"] },
			'publication' => { 'literal'  => ["${cvx}publication"] },
			'skill'       => { 'literal'  => ["${cvx}skill"] },
			},
	};
	
	return $rv;
}

sub add_to_model
{
	my $self  = shift;
	my $model = shift;

	$self->_simple_rdf($model);
	
	my $cv  = "http://purl.org/captsolo/resume-rdf/0.2/cv#";
	my $rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
	my $cvx = "http://ontologi.es/hresume#";

	if (defined $self->data->{'contact'})
	{
		$model->add_statement(RDF::Trine::Statement->new(
			$self->id(1),
			RDF::Trine::Node::Resource->new("${cv}aboutPerson"),
			$self->id(1, 'holder'),
			));
		
		$self->data->{'contact'}->add_to_model($model);
	}

	foreach my $experience (@{$self->data->{'experience'}})
	{
		$model->add_statement(RDF::Trine::Statement->new(
			$self->id(1),
			RDF::Trine::Node::Resource->new("${cv}hasWorkHistory"),
			$experience->id(1, 'experience'),
			));
			
		$model->add_statement(RDF::Trine::Statement->new(
			$experience->id(1, 'experience'),
			RDF::Trine::Node::Resource->new("${rdf}type"),
			RDF::Trine::Node::Resource->new("${cv}WorkHistory"),
			));
		
		$model->add_statement(RDF::Trine::Statement->new(
			$experience->id(1, 'experience'),
			RDF::Trine::Node::Resource->new("${cvx}ical-component"),



( run in 1.658 second using v1.01-cache-2.11-cpan-39bf76dae61 )