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
goffihas left
goffihas joined
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? :)
sonnyhas joined
malthehas left
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
Samhas left
MattJPlease please please
Samhas joined
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 :)
jonas’nx?
lovetox*ns
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
Mx2has left
lovetoxat least the expat api that is accessible via python
Mx2has joined
marc0shas left
marc0shas joined
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
lovetoxjonas’, i use currently xml.parsers.expat.ParserCreate
lovetoxis there any benefit of using the sax module?
jonas’less boiler plate to write I guess
dezanthas left
dezanthas joined
jonas’I strongly suggest to go with the high-level SAX API, it saves you worrying about namespace prefixes and stuff.
malthehas joined
debaclehas joined
lovetoxok i look into it
rom1dephas joined
resethas joined
resetn
DebXWoodyhas joined
nephelehas joined
Marandahas left
stpeterhas joined
marc0shas left
marc0shas joined
marc0shas left
marc0shas joined
antranigvhas left
antranigvhas joined
Marandahas joined
marc0shas left
marc0shas joined
raghavgururajanhas left
debaclehas left
antranigvhas left
stpeterhas left
malthehas left
inkyhas joined
Mx2has left
Mx2has joined
raghavgururajanhas joined
malthehas joined
inkyhas left
goffihas left
goffihas joined
xeckshas joined
malthehas left
selurveduhas left
nephelehas left
nephelehas joined
goffihas left
goffihas joined
alacerhas joined
alacerhas left
alacerhas joined
goffihas left
goffihas joined
nephelehas left
nephelehas joined
xeckshas left
resethas left
resethas joined
emushas joined
raghavgururajanhas left
lovetoxand all the prefix stuff is just to save on size? it does not add some new feature to xml? so if a client does not use ns prefixes at all its perfectly fine?
Zashprefix stuff is generally not used in XMPP, apart from for <stream:stream> and Dialback
ZashDoes it not add the ability to namespace attributes? I.e how else would you say `<e xmlns:foo="urn:example:ns" foo:bar="blah"/>` ?
Zash(Which is also pretty rare in XMPP)
lovetoxyeah it does, forgot about the attribute stuff
lovetoxits weird in one example the stream prefix is used
lovetoxin others not in the rfc
ZashHm?
ZashLike `<stream ....` ? Probably just to make the examples more compact
lovetoxbut without defining it on the stream element, this would indeed be very wasteful
Mx2has left
Mx2has joined
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"/>`
malthehas left
resettest
goffihas left
resethmm
ZashThis was a triumph! I'm making a note here: HUGE SUCCESS!