Skip to content

Parser does not recognize namespaced attributes #10

Description

@ostinelli

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='juliet@im.example.com' 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">>,<<"juliet@im.example.com">>},
                          {<<"to">>,<<"im.example.com">>},
                          {<<"version">>,<<"1.0">>},
                          {<<"xml:lang">>,<<"en">>}],
                         []}]},
    [{xmlstreamstart,<<"stream:stream">>,
                     [{<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},
                      {<<"from">>,<<"juliet@im.example.com">>},
                      {<<"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='juliet@im.example.com' to='im.example.com' version='1.0' xml:lang='en' xmlns='jabber:client'>">>).
{ok,{parser,<<>>,
            [{xmlelement,<<"stream:stream">>,
                         [{<<"xmlns">>,<<"jabber:client">>},
                          {<<"from">>,<<"juliet@im.example.com">>},
                          {<<"to">>,<<"im.example.com">>},
                          {<<"version">>,<<"1.0">>},
                          {<<"xml:lang">>,<<"en">>}],
                         []}]},
    [{xmlstreamstart,<<"stream:stream">>,
                     [{<<"xmlns">>,<<"jabber:client">>},
                      {<<"from">>,<<"juliet@im.example.com">>},
                      {<<"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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions