lovetoxdoes a element name like <stream:stream> in xml has a special meaning because of the ":" or is this just a element name like any other and ":" has no special meaning
lovetoxi tried to find it in the xml spec, but this thing is unreadable for me
flowlovetox, IIRC it has no special meaning if there are no XML namespaces
flowI think https://www.w3.org/TR/xml-names/ is what gives ":" in xml element names a special semantic
flowSo as soon as you use namespaces, which is probably true for most practical usages of XML, it has a special meaning
MattJIncluding in XMPP
flowlovetox, but I am curious, as it look like there is some more backstory to this question. if so, would you mind elaborating a bit? :)
lovetoxthe backstory is i try to rewrite the nbxmpp streamparser and now i have to understand this :)
flowlovetox, I'd hoped that python has a good xml pull parser library that you could re-use?
flowotherwise I feel like you will hit a few xml trapdoors and probably re-work your implementation 2-3 times :)
flowbut you will learn a lot about XML in the process, so not sure if this will be a loss, just be prepared
MattJ500% use an existing parser
MattJPlease please please
flowmake sure to look at existing APIs. I think Java's StAX is a very good example of an XML stream parser
jonas’the standard library parser is good enough for that
jonas’it is based on Expat and does SAX
jonas’please use that.
MattJexpat is a great choice
Zashjust remember to disable all the security holes
jonas’it can be used non-blockingly. If you need proof, look at aioxmpp.
Zashat least that's easier than reinventing the security holes yourself
lovetoxcalm down, i use expat
flowjonas’, isn't SAX a push parser? when can those not be used non-blockingly?
lovetoxstill need to understand xml namespaces
MattJI think recent expat versions have more sensible defaults, though forbidden XMPP stuff will still need handling
jonas’lovetox, do you? the parser should do all that for you.
jonas’(and expat does if you ask nicely)
jonas’(and by extension, the python standard library xml module does)
flowI think you need to understand XML when parsing XML, and even if not, it can't hurt ;)
jonas’https://github.com/horazont/aioxmpp/blob/devel/aioxmpp/xml.py#L818-L1111 explicitly waiving the infectiousness of the *GPL for you, lovetox, if you need/use that as inspiration.
lovetoxjonas’, if i search for nx prefix in that code, i find a lot of matches
lovetoxthanks flow, that document did help to understand prefixes :)
lovetoxregarding your comment, that its not necessary to understand and python xml libs do it for you
MattJThe summary is that the element called "foo" in one namespace is not the same as the element called "foo" in another namespace. A namespace is identified by a string, usually found in the 'xmlns' attribute. Prefixes are simply a more concise replacement for adding 'xmlns' attributes everywhere (you declare them once and use them as many times as you want)
MattJThis looks like a sane explanation: http://tech.usgin.org/content/xml-namespaces-and-prefixes
MattJXMPP is heavily based on XML namespaces, so understanding them is not really optional for an XMPP dev. But a good parser (such as expat) will save you from having to handle all the rules (such as inheritance) yourself, and it will tell you what namespace every element is in (regardless of whether it used a prefix or an xmlns attribute)
lovetoxyes that would be nice
lovetoxi just tested expat
lovetoxand it does not handle it
lovetoxat least the expat api that is accessible via python
lovetoxhm altough some examples show it does, maybe i need to investigate this more
lovetoxExpat can optionally do XML namespace processing for you, enabled by providing a value for namespace_separator
lovetoxbut without defining it on the stream element, this would indeed be very wasteful
ZashSo if you could be certain that the other end of the stream understands namespaces and prefixes fully, you could cut down on repeated namespace declaration for common things. Like imagine `<sm:r/>` instead of `<r xmlns="urn:xmpp:sm:3"/>`
ZashThis was a triumph! I'm making a note here: HUGE SUCCESS!