HTML-Microformats
view release on metacpan or search on metacpan
lib/HTML/Microformats/DocumentContext.pm view on Meta::CPAN
{
$self->{'representative_hcard'} = $hc;
last HCARD;
}
}
}
# unless ($self->{'representative_hcard'})
# {
# $self->{'representative_hcard'} = $hcards[0] if @hcards;
# }
if ($self->{'representative_hcard'})
{
$self->{'representative_hcard'}->{'representative'} = 1;
}
}
return $self->{'representative_hcard'};
}
sub representative_person_id
{
my $self = shift;
my $as_trine = shift;
my $hcard = $self->representative_hcard;
if ($hcard)
{
return $hcard->id($as_trine, 'holder');
}
unless (defined $self->{'representative_person_id'})
{
$self->{'representative_person_id'} = $self->make_bnode;
}
if ($as_trine)
{
return ($self->{'representative_person_id'} =~ /^_:(.*)$/) ?
RDF::Trine::Node::Blank->new($1) :
RDF::Trine::Node::Resource->new($self->{'representative_person_id'});
}
return $self->{'representative_person_id'};
}
sub contact_hcard
{
my $self = shift;
unless ($self->{'contact_hcard'})
{
my @hcards = HTML::Microformats::Format::hCard->extract_all($self->document->documentElement, $self);
my ($shallowest, $shallowest_depth);
HCARD: foreach my $hc (@hcards)
{
next unless ref $hc;
my $address = searchAncestorTag('address', $hc->element);
next unless defined $address;
my @bits = split m'/', $address;
my $address_depth = scalar(@bits);
if ($address_depth < $shallowest_depth
|| !defined $shallowest)
{
$shallowest_depth = $address_depth;
$shallowest = $hc;
}
}
$self->{'contact_hcard'} = $shallowest;
if ($self->{'contact_hcard'})
{
$self->{'contact_hcard'}->{'contact'} = 1;
}
}
return $self->{'contact_hcard'};
}
sub contact_person_id
{
my $self = shift;
my $as_trine = shift;
my $hcard = $self->contact_hcard;
if ($hcard)
{
return $hcard->id($as_trine, 'holder');
}
unless (defined $self->{'contact_person_id'})
{
$self->{'contact_person_id'} = $self->make_bnode;
}
if ($as_trine)
{
return ($self->{'contact_person_id'} =~ /^_:(.*)$/) ?
RDF::Trine::Node::Blank->new($1) :
RDF::Trine::Node::Resource->new($self->{'contact_person_id'});
}
return $self->{'contact_person_id'};
}
sub _process_langs
{
my $self = shift;
my $elem = shift;
my $lang = shift;
if ($elem->hasAttributeNS(XML_XML_NS, 'lang'))
{
$lang = $elem->getAttributeNS(XML_XML_NS, 'lang');
}
elsif ($elem->hasAttribute('lang'))
{
$lang = $elem->getAttribute('lang');
}
( run in 1.239 second using v1.01-cache-2.11-cpan-71847e10f99 )