exml icon indicating copy to clipboard operation
exml copied to clipboard

Parser does not recognize namespaced attributes

Open ostinelli opened this issue 13 years ago • 1 comments

When I try to parse a <stream> element, the parser does not understand the difference between namespaced attributes.


1> {ok, Parser} = exml_stream:new_parser().
{ok,{parser,<<>>,[]}}
2> {ok, _, _} = exml_stream:parse(Parser, <<"<?xml version='1.0'?><stream:stream from='[email protected]' to='im.example.com' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>">>).
{ok,{parser,<<>>,
            [{xmlelement,<<"stream:stream">>,
                         [{<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},
                          {<<"from">>,<<"[email protected]">>},
                          {<<"to">>,<<"im.example.com">>},
                          {<<"version">>,<<"1.0">>},
                          {<<"xml:lang">>,<<"en">>}],
                         []}]},
    [{xmlstreamstart,<<"stream:stream">>,
                     [{<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},
                      {<<"from">>,<<"[email protected]">>},
                      {<<"to">>,<<"im.example.com">>},
                      {<<"version">>,<<"1.0">>},
                      {<<"xml:lang">>,<<"en">>}]}]}
3> {ok, Parser2} = exml_stream:new_parser().
{ok,{parser,<<>>,[]}}
4> {ok, _, _} = exml_stream:parse(Parser2, <<"<?xml version='1.0'?><stream:stream xmlns:stream='http://etherx.jabber.org/streams' from='[email protected]' to='im.example.com' version='1.0' xml:lang='en' xmlns='jabber:client'>">>).
{ok,{parser,<<>>,
            [{xmlelement,<<"stream:stream">>,
                         [{<<"xmlns">>,<<"jabber:client">>},
                          {<<"from">>,<<"[email protected]">>},
                          {<<"to">>,<<"im.example.com">>},
                          {<<"version">>,<<"1.0">>},
                          {<<"xml:lang">>,<<"en">>}],
                         []}]},
    [{xmlstreamstart,<<"stream:stream">>,
                     [{<<"xmlns">>,<<"jabber:client">>},
                      {<<"from">>,<<"[email protected]">>},
                      {<<"to">>,<<"im.example.com">>},
                      {<<"version">>,<<"1.0">>},
                      {<<"xml:lang">>,<<"en">>}]}]}

In the first parser, the xml has the xmlns attribute first and the xmlns:stream attribute second. As you can see, the result only includes the second attribute xmlns:stream.

In the second parser, the xml has the xmlns:stream attribute first and the xmlns attribute second. As you can see, the result only includes the second attribute xmlns.

Desired: both attributes should be kept, as per the XMPP protocol.

ostinelli avatar Oct 21 '12 00:10 ostinelli

I would mention that I do not observe beforementioned issue on the current master.

Should it be closed, so as to stop people from trying out this project on their own? The issue sounds pretty rough.

keynslug avatar Sep 09 '14 08:09 keynslug