Jonathan Chayce Dickinson
chayce.za at gmail.com
Mon Sep 3 18:06:38 UTC 2007
Michal 'vorner' Vaner wrote:
> But, as you noticed, you probably need a home-grown XML syntethyzer,
> since you are not allowed to put many other things into the XML stream
> (like processing instructions). And you need at last to modify that one
> to handle attributes in different namespace than their tag. They need to
> generate and place XML namespace prefixes there, remember them, atc.
Very, very true. Everyone is gallivanting around with code like (as far
as I have seen AGSXMPP and XMPP4R):
if(node.prefix == "stream" && node.localName == "stream")
// Start of the stream.
That is WRONG. It should rather be:
if(node.namespace == "http://etherx.jabber.org/streams" &&
node.localName == "stream")
// Start of stream.
So having to predefine prefixes, while nice, is completely unnecessary,
and when a programmer comes along who wants to write proper code,
everyone else falls over, because they aren't doing it properly: and
then his program will be seen as the one with issues.
If your XML serializer shouldn't really be generating invalid XML, it
only puts what you ask it to in the stream. The initial <?xml [...]?> PI
is perfectly valid, and is even in some of the examples in certain XEPs.
If you HAVE to use a homegrown parser, at least do it properly. There
are numerous examples of XML parsers written in C++, namespaces are
easily handled using Stacks. Otherwise, look at Expat.
If you want, feel free to IM me, I would be more than happy to help you
make MCabber more XML conformant.
> As I said, your way is 100% valid and correct. But I just think the way
> with separate tag will cause in less effort implementing it. Is there
> any advantage in your way? If there is, I have no objections using it.
Let's look at the following packets, they are delimited using a
horizontal line. The client will only 'wake-up' about the smilies when
the second packet is received (which is no big mission for this
instance, but is a disaster for larger messages).
This is a test :).
<smilie from="15" length="2" />
And, putting the tags directly in the text is SOOOO much more elegant.
If you have a good XML parser, the implementation falls away, because in
your case (where you don't handle emoticons) you can simply say the
as opposed to
jonathan chayce dickinson
email: chayce.za at gmail.com
jabber: moitoi at inflecto.org
<some profound piece of wisdom>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6974 bytes
Desc: S/MIME Cryptographic Signature
More information about the Standards