XML-Generator-vCard

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    This is called by the *_render_instantmessaging* method.

NAMESPACES
    This package generates SAX events using the following XML namespaces :

    * vCard
         x-urn:cpan:ascope:xml-generator-vcard#

    * foaf:
         http://xmlns.com/foaf/0.1/

HOW TO
  Filter cards by category
     package MyGenerator;
     use base qw (XML::Generator::vCard);

     sub _render_card {
         my $self = shift;
         my $card = shift;

         my $cats = $vcard->get({"node_type" => 'categories'}) ||
                    $vcard->get({"node_type" => 'category'});

         if (! $cats) {
             return 1;
         }
     
         if (! grep { $_->value() eq "foo" } split(",",$cats->[0])) {
             return 1;
         }

         return $self->SUPER::_render_card($vcard);
     }

     package main;

     my $writer = XML::SAX::Writer->new();
     my $parser = MyGenerator->new(Handler=>$writer);

     $parser->parse_files(@ARGV);

  Generate SAX events for a custom 'X-*' field
     package MyGenerator;
     use base qw (XML::Generator::vCard);

     sub _render_custom {
       my $self  = shift;
       my $vcard = shift;

       my $custom = $vcard->get({"node_type" => "x-foobar"});
        
       if (! $addresses) {
          next;
       }

       foreach my $foo (@$custom) {
        
          my $types = join(";",$foo->types());

          $self->_pcdata({Name       => "foo:bar",
                          Value      => $foo->value(),
                          Attributes => {"{}type"=> {Name  => "type",
                                                     Value => $types}}
                          });
       }

       return 1;
     }
 
     package main;

     my $writer = XML::SAX::Writer->new();
     my $parser = MyGenerator->new(Handler=>$writer);

     $parser->parse_files(@ARGV);

  Add custom namespaces
     package MyGenerator;
     use base qw (XML::Generator::vCard);

     sub namespaces {
         my $self = shift;
     
         my $ns = $self->SUPER::namespaces();
         $ns->{ "foo" } = "x-urn:foo:bar#";

         return $ns;
     }

     package main;

     my $writer = XML::SAX::Writer->new();
     my $parser = MyGenerator->new(Handler=>$writer);

     $parser->parse_files(@ARGV);

VERSION
    1.3

DATE
    $Date: 2004/12/28 23:31:29 $

AUTHOR
    Aaron Straup Cope <ascope@cpan.org>

SEE ALSO
    Text::vCard

    XML::Generator::vCard::Base

    http://www.ietf.org/rfc/rfc2426.txt

    http://www.ietf.org/rfc/rfc2425.txt

BUGS
    vCards containg binary PHOTO images may cause Perl to segfault on Mac
    OSX and come flavours of Linux (but not FreeBSD.) The source of this
    problem has been traced, I think, to a regular expression issue in the
    Perl Text::ParseWords library. A bug report has been filed.



( run in 0.637 second using v1.01-cache-2.11-cpan-e1769b4cff6 )