SYNOPSIS

 use RDF::vCard;

 my $input    = "http://example.com/contact-data.rdf";
 my $exporter = RDF::vCard::Exporter->new(vcard_version => 3);

 print $_ foreach $exporter->export_cards($input);

DESCRIPTION

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

Constructor

  • \*(C`new(%options)\*(C' Returns a new RDF::vCard::Exporter object. Options:

    • vcard_version - '3' or '4'. This module will happily use vCard 3.0 constructs in vCard 4.0 and vice versa. But in certain places it can lean one way or the other. This option allows you to influence that.

Methods

  • \*(C`export_cards($input, %options)\*(C' Returns a list of vCards found in the input, in no particular order. The input may be a \s-1URI\s0, file name, RDF::Trine::Model or anything else that can be handled by the \*(C`rdf_parse\*(C' method of RDF::TrineShortcuts. Supported options include sort which, if set to true, causes the output to be sorted by name (as well as is possible); source which allows you to provide the \s-1URL\s0 where the cards were sourced from; and prodid which allows you to set the product \s-1ID\s0 used in the output. (A prodid must be in \s-1FPI\s0 format to be valid, though the module doesn't check this. undef is allowed. By default, RDF::vCard:Exporter uses its own prodid, and unless you have a good reason to change this, you should probably let it.) e.g. my @cards = $exporter->export_cards( $some_data, sort => 1, source => 'http://bigcorp.example.com/data.rdf', prodid => '+//IDN example.net//NONSGML MyScript v 0.1//EN', ); Each item in the list returned is an RDF::vCard::Entity, though that class overloads stringification, so you can just treat each item as a string mostly.

  • \*(C`export_card($input, $subject, %options)\*(C' As per \*(C`export_cards\*(C' but exports just a single card. The subject provided must be an RDF::Trine::Node::Blank or RDF::Trine::Node::Resource of type v:VCard.

  • \*(C`is_v3\*(C' Returns true if this exporter is in vCard 3.0 mode.

  • \*(C`is_v4\*(C' Returns true if this exporter is in vCard 4.0 mode.

\s-1RDF\s0 Input

Input is expected to use 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 supported. (Namely: vx:usage, vx:kind, vx:gender, vx:sex, vx:dday, vx:anniversary, vx:lang, vx:caladruri, vx:caluri, vx:fburl, vx:impp, vx:source.)

The module author has made the decision not to support \s-1FOAF\s0 and other \s-1RDF\s0 vocabularies that may be used to model contact information for people and organisations, as they do not necessarily map cleanly onto vCard. People hoping to map non-vCard \s-1RDF\s0 to vCard using this module may have some luck pre-processing their \s-1RDF\s0 using a rules-based reasoner.

vCard Output

The output of this module mostly aims at vCard 3.0 (\s-1RFC\s0 2426) compliance. In the face of weird input data though, (e.g. an \s-1FN\s0 property that is a \s-1URI\s0 instead of a literal) it can pretty easily descend into exporting junk, non-compliant vCards.

Many vCard 4.0 properties, such as the \s-1IMPP\s0 and \s-1KIND\s0, are also supported.

The vcard_version constructor option allows you to influence how some properties like \s-1GEO\s0 and \s-1TEL\s0 (which differ between 3.0 and 4.0) are output.

RELATED TO RDF::vCard::Exporter…

RDF::vCard, HTML::Microformats, RDF::TrineShortcuts.

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.