[ejabberd] EXMPP and PubSub Publishing

Pablo Polvorin pablo.polvorin at process-one.net
Thu Sep 24 18:11:19 MSD 2009


Hi Tristan,

Not sure if this is the root cause, but when constructing the
elements, you are mixing attributes and namespaces. In exmpp, those
are managed in different ways, that's why your generated XML has
*two* xmlns declarations:

>            <topics xmlns=\"\" xmlns=\"http://www.chatyeo.com/2009/Topics\">

I think what you are trying is:
#xmlel{ns = "http://www.chatyeo.com/2009/Topics",
           name=topics,
            attrs=[],
            children=[#xmlel{ns = "http://www.chatyeo.com/2009/Topics",
                                     name=topic,
                                     children=[#xmlcdata{cdata= <<"Rza">>}]}]

(note that you *must* supply the ns for the child too, it won't appear
in the XML text  because it is
  already the default namespace).

As a side note, the API is the preferred way to build elements
(although in simple cases like this it is ok to build the records
directly):
-define(NS, "http://www.chatyeo.com/2009/Topics").
exmpp_xml:element(?NS, topics, [],
    [exmpp_xml:element(?NS, topic, [],
        [exmpp_xml:cdata(<<"Rza">>)])])


hope this helps

2009/9/23 Tristan Sloughter <kungfooguru at gmail.com>:
> I build and send it with:
>
> XML = [#xmlel{name=topics, attrs=[#xmlattr{name=xmlns, value=
> <<"http://www.chatyeo.com/2009/Topics">>}], children=[#xmlel{name=topic,
> children=[#xmlcdata{cdata= "Rza"}]}]}],
> exmpp_session:send_packet(Session,
> exmpp_client_pubsub:publish(<<"pubsub.localhost">>,
> "/home/localhost/another_10/test_4", XML)),
>
> the result for the publish that constructs the XML is:
>
> "<iq xmlns=\"jabber:client\" type=\"set\" to=\"pubsub.localhost\"
> id=\"pubsub-899574700\">
>     <pubsub xmlns=\"http://jabber.org/protocol/pubsub\">
>       <publish node=\"/home/localhost/another_10/test_4\">
>         <item>
>            <topics xmlns=\"\" xmlns=\"http://www.chatyeo.com/2009/Topics\">
>              <topic>Rza</topic>
>             </topics>
>         </item>
>       </publish>
>     </pubsub>
>   </iq>"
>
> On Wed, Sep 23, 2009 at 2:23 PM, Pablo Polvorin
> <pablo.polvorin at process-one.net> wrote:
>>
>> Hi,
>> could you provide more details? that will help us identify what is going
>> on.
>> How are you building the publish stanzas?.  What XML is generated?
>> ( you can see the xml sent  by raising ejabberds's loglevel  or  by
>> printing
>>  the results of  exmpp_xml:document_to_list(YourStanza) )
>>
>>
>>
>>
>> 2009/9/23 Tristan Sloughter <kungfooguru at gmail.com>:
>> > I've gotten creating and subscribing to nodes working fine with EXMPP
>> > and
>> > EJabberd 2.0.5 and 2.1rc1; however, I could only successfully publish a
>> > list
>> > of a single #xmlcdata element on 2.0.5 and nothing at all on 2.1rc1.
>> > Obviously, I'd like to be able to publish a list of #xmlel elements as
>> > the
>> > item or items. There is no useful error message when I attempt to
>> > publish to
>> > a node I created. The only message is:
>> >
>> > =INFO REPORT==== 2009-09-23 13:24:37 ===
>> > I(<0.410.0>:ejabberd_c2s:1326) :
>> > ({socket_state,gen_tcp,#Port<0.3412>,<0.409.0>}) Close session for
>> > another_10 at localhost/exmpp#1253730276407777
>> >
>> > Does anyone have any guess as to what could be causing this to happen?
>> > I'm
>> > lost for ideas at this point...
>> >
>> > Thanks,
>> > Tristan
>> >
>> > _______________________________________________
>> > ejabberd mailing list
>> > ejabberd at jabber.ru
>> > http://lists.jabber.ru/mailman/listinfo/ejabberd
>> >
>> >
>>
>>
>>
>> --
>> Pablo Polvorin
>> ProcessOne
>> _______________________________________________
>> ejabberd mailing list
>> ejabberd at jabber.ru
>> http://lists.jabber.ru/mailman/listinfo/ejabberd
>
>
> _______________________________________________
> ejabberd mailing list
> ejabberd at jabber.ru
> http://lists.jabber.ru/mailman/listinfo/ejabberd
>
>



-- 
Pablo Polvorin
ProcessOne


More information about the ejabberd mailing list