[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [JDEV] Protocol bits and discussion
> I will just jump in here with some general questions
> about XML design which have come up on another list.
> JABBER provides a good example of the issues. I am not
> quarelling with the approach Jeremie has taken but
> would like to understand the design issues better.
Yes, excellent, please feel free to ask since I'm sure you're probably not
the only one wondering :)
> ><login>
> > <user>test</user>
> > <pass>test</pass>
> > <nick>test user</nick>
> ></login>
> >
>
> An alternative would be
> <login user="test" pass="test" nick="test user" >
> </login>
>
> etc ... when and why does one use tags versus
> providing attributes to tags?
>
> ...
GOOD question! Well, from a processor or programming point of view, it
doesn't really matter all that much. It's really a combination of both, a
sort of balance, that turns out to be the best.
In Jabber's case, there are a few good reasons to structure it as it is:
at some point in the future the protocol might expand in unforseen ways,
say you wanted to support a special type of password that was incompatible
with anything else, you could easily:
<login>
<user>test</user>
<pass type='test'>test</pass>
<nick>test</nick>
</login>
So that all of the "old" servers and clients would simply ignore the new
optional type='' attribute. It works out much more cleanly with the
current approach.
A kind of general rule of thumb is that you wrap "core data" with tags,
and you place any optional attributes of that core data in attributes. So
the core data of every packet is a sub-tag, and any attributes of that
data is described with attributes in those tags.
Right now there aren't many attributes, but as more is demanded of Jabber
I'd expect that more optional attributes will pop up over time(for example
<icon src='http://asdf/mystatus.gif'>away</icon> might be a future
possibility)
Does this make sense?
Thanks,
Jer