AddExtension is modified to accept both key/value pairs and xml elements.

parent e558b481
......@@ -180,13 +180,30 @@ sub AddCapability($$$)
# Add an extension. Each extension is an xml element.
# If the element is in a different namespace it has to be specified
# during element construction.
sub AddExtension($$)
# It also accepts key/value pairs. When key/value pair is specified
# It converts them to <key>value</key> xml element and
# adds under extensions.
sub AddExtension
{
my ($self, $elem) = @_;
my $self = shift;
my $elem = undef;
return -1
if (!ref($self));
if (!ref($self));
my $root = GeniXML::Parse($self->{'extensions'});
return -1
if (!defined($root));
if (1 == @_) {
# it means xml element is specified.
$elem = shift;
}elsif (2 == @_){
# it means key/value pair is specified.
$elem = XML::LibXML::Element->new(@_[0]);
$elem->appendText(@_[1]);
}else {
return -1;
}
$root->appendChild($elem);
$self->{'extensions'} = GeniXML::Serialize($root);
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment