The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XML::CAP - parse or generate the XML Common Alerting Protocol (CAP)

VERSION

Version 0.02

SYNOPSIS

XML::CAP parses and generates XML Common Alerting Protocol (CAP).

More information about CAP can be found at http://www.incident.com/cookbook/

Each XML CAP structure has an "alert" section. Each alert may contain zero (usually one) or more "info" sections. Each info section may contain zero or more "resource" and/or "area" sections. Each area section may contain zero or more "geocode" sections. All of these sections are represented by subclasses of XML::CAP.

XML::CAP uses XML::LibXML. There are accessor functions for every element. But using the elem() method, there is also direct access to the corresponding LibXML node.

Code sample:

    use XML::CAP;
    use XML::CAP::Parser;

    my $parser = XML::CAP::Parser->new();
    $parser->parse_file( "cap-file.xml" );
    my $alert;
    eval_wrapper ( sub { $alert = $parser->alert });

    @alert_nodes = $alert->elem->childnodes; # access to XML::libXML data
    $identifier = $alert->identifier;
    $sender = $alert->sender;
    $sent = $alert->sent;
    $status = $alert->status;
    $msgType = $alert->msgType;
    $source = $alert->source;
    $scope = $alert->scope;
    $restriction = $alert->restriction;
    $addresses = $alert->addresses;
    $code = $alert->code;
    $note = $alert->note;
    $references = $alert->references;
    $incidents = $alert->incidents;

    my @infos = $alert->infos;
    @info_nodes = $infos[0]->elem->childnodes; # access LibXML data
    my $info = $infos[0];
    $language = $info->language;
    $category = $info->category;
    $event = $info->event;
    $responseType = $info->responseType;
    $urgency = $info->urgency;
    $severity = $info->severity;
    $certainty = $info->certainty;
    $audience = $info->audience;
    $eventCode = $info->eventCode;
    $effective = $info->effective;
    $onset = $info->onset;
    $expires = $info->expires;
    $senderName = $info->senderName;
    $headline = $info->headline;
    $description = $info->description;
    $instruction = $info->instruction;
    $web = $info->web;
    $contact = $info->contact;
    $parameter = $info->parameter;

    my @resources = $info->resources;
    @resource_nodes = $resources[0]->elem->childnodes; # access LibXML data
    my $resource = $resources[0];
    $resourceDesc = $resource->resourceDesc;
    $mimeType = $resource->mimeType;
    $size = $resource->size;
    $uri = $resource->uri;
    $derefUri = $resource->derefUri;
    $digest = $resource->digest;

    my @areas = $info->areas;
    @area_nodes = $areas[0]->elem->childnodes; # access LibXML data
    my $area = $areas[0];
    $areaDesc = $area->areaDesc;
    $polygon = $area->polygon;
    $circle = $area->circle;
    $altitude = $area->altitude;

    my @geocodes = $area->geocodes;
    @geocode_nodes = $geocodes[0]->elem->childnodes; # access LibXML data
    my $geocode = $geocodes[0];
    $valueName = $geocode->valueName;
    $value = $geocode->value;

FUNCTIONS

new

initialize

eval_wrapper ( $code, $throw_func, [ name => value, ...] )

AUTHOR

Ian Kluft, <ikluft at cpan.org>

BUGS

Please report any bugs or feature requests to bug-xml-cap at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-CAP. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc XML::CAP

You can also look for information at:

ACKNOWLEDGEMENTS

The initial version was derived from XML::Atom by Benjamin Trott and Tatsuhiko Miyagawa.

COPYRIGHT & LICENSE

Copyright 2009 Ian Kluft, all rights reserved.

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