SYNOPSIS

 use RDF::vCard;
 use RDF::TrineShortcuts qw':all';

 my $importer = RDF::vCard::Importer->new;
 print $_
        foreach $importer->import_file('contacts.vcf');
 print rdf_string($importer->model => 'RDFXML');

DESCRIPTION

This module reads vCards and writes \s-1RDF\s0.

Constructor

  • \*(C`new(%options)\*(C' Returns a new RDF::vCard::Importer object and initialises it. The only valid option currently is ua which can be set to an LWP::UserAgent for those rare occasions that the Importer needs to fetch stuff from the Web.

Methods

  • \*(C`init\*(C' Reinitialise the importer. Forgets any cards that have already been imported.

  • \*(C`model\*(C' Return an RDF::Trine::Model containing data for all cards that have been imported since the importer was last initialised.

  • \*(C`import_file($filename, %options)\*(C' Imports vCard data from a file on the file system. The data is added to the importer's model (and can be retrieved using the \*(C`model\*(C' method). This function returns a list of RDF::vCard::Entity objects, so it's also possible to access the data that way. There is currently only one supported option: \*(C`lang\*(C' which takes an \s-1ISO\s0 language code indicating the default language of text within the vCard data.

  • \*(C`import_fh($filehandle, %options)\*(C' As per \*(C`import_file\*(C', but operates on a file handle.

  • \*(C`import_string($string, %options)\*(C' As per \*(C`import_file\*(C', but operates on vCard data in a string.

  • \*(C`import_url($url)\*(C' As per \*(C`import_file\*(C', but fetches vCard data from a Web address. Sends an \s-1HTTP\s0 Accept header of: text/directory;profile=vCard, text/vcard, text/x-vcard, text/directory;q=0.1

vCard Input

vCard 3.0 should be supported fairly completely. Some vCard 4.0 constructs will also work.

Much of the heavy lifting is performed by Text::vFile::asData, so this module may be affected by bugs in that distribution.

\s-1RDF\s0 Output

Output uses the newer of the 2010 revision of the W3C's vCard vocabulary http://www.w3.org/Submission/vcard-rdf/ <http://www.w3.org/Submission/vcard-rdf/>. (Note that even though this was revised in 2010, the term URIs include \*(L"2006\*(R" in them.)

Some extensions from the namespace <http://buzzword.org.uk/rdf/vcardx#> are also output.

The \s-1AGENT\s0 property is currently omitted from output. This will be added in a later version.

RELATED TO RDF::vCard::Importer…

RDF::vCard.

http://www.w3.org/Submission/vcard-rdf/ <http://www.w3.org/Submission/vcard-rdf/>.

<http://www.perlrdf.org/>.

AUTHOR

Toby Inkster <[email protected]>.

COPYRIGHT

Copyright 2011 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.