[jdev] using DefineNamespace in Net::Jabber
andrew
kaspicka at shaw.ca
Sun Sep 4 16:53:05 CDT 2005
Hello,
I'm having some problems with trying to figure out DefineNamespace in the
perl Net::Jabber lib. I was wondering if anybody would be able to give me
any pointers?
I have the following that works fine...
# <query xmlns="mycomp:iq:func" type="result">
# <action attrib="XXX">YYY</action>
# </query>
$component->DefineNamespace(xmlns=>"mycomp:iq:func",
type=>"Query",
functions=>[{name=>"attrib",
path=>"action/\@attrib",
},
{name=>"Query",
path=>"action/text()",
}]);
Which allows me to use the generated functions like so...
my $iq = $elem->NewQuery("mycomp:iq:func");
$iq->SetAttrib($attrib);
$iq->SetAction($action);
Now I want to do things a bit differently. I would like to be able to allow
more than one <action> tag in the query.
So...
# <query xmlns="mycomp:iq:func" type="result">
# <action attrib="XXX">YYY</action>
# <action attrib="XXX">YYY</action>
# etc.
# </query>
Doing the following doesn't work...
my $iq = $elem->NewQuery("mycomp:iq:func");
$iq->SetAttrib($attrib);
$iq->SetAction($action);
$iq->SetAttrib($attrib2);
$iq->SetAction($action2);
It creates one <action> with the $attrib2 and $action2 data, which isn't
really unexpected.
>From reading the docs for DefineNamespace it looks like I might have to
create more than one namespace for this somewhat in the fashion used for
roster items, but I'm not really sure how to accomplish this with
DefineNamespace.
Any help appreciated... thanks!
Andrew
More information about the JDev
mailing list