jdev - 2023-05-20


  1. fuku

    hello

  2. Alif Radhitya

    Ya

  3. defanor

    I am trying to compose a nice XML structure for an XMPP client library in C (for use from C, Rust, and other languages via bindings), something to replace libxml2's xmlNode with: ideally something clean, not allowing nonsense structures to be defined, least error-prone, and so on. Currently thinking of giving up on concrete syntax (even on prefixes: just keep track of namespace URIs and names between parsing + analysis and writing), but it is scary to jump into a large rewrite without being quite sure how it will work out. Has anybody here tried to work with XMPP using a structure without namespace prefixes, and/or are there any C (or similar) XML structures you were happy with in XMPP software?

  4. jonas’

    defanor, yes

  5. jonas’

    aioxmpp (python) does not keep track of prefixes, *but* what you will need is to force specific prefixes on serialization (for stream:stream at least)

  6. jonas’

    and you'll need a serializer which avoids the use of prefixes at all cost, except for stream:stream, because some implementations cannot deal with it.

  7. jonas’

    other than those two caveats, you can do away entirely with the prefix physical representation and you should :-)

  8. defanor

    jonas’, indeed, had in mind perhaps predefining a few, and straem:stream in particular. Thanks, will check aioxmpp's structures now.

  9. jonas’

    aioxmpp has no concept of XML nodes at the structure level, mind

  10. jonas’

    it directly transforms from SAX into node-specific objects

  11. jonas’

    (with no intermediate representation which would fit something like libxml2 xmlNode)

  12. defanor

    Ah. Well, at least will probably jump into a rewrite more easily.

  13. jonas’

    that's probably not feasible to do in C, so probably not useful to look into :-)

  14. jonas’

    good luck :)

  15. jonas’

    which software is that in context of, if I may ask?

  16. defanor

    Thanks. That's for rexmpp (<https://git.uberspace.net/rexmpp/>): I actually thought of introducing a custom XML structure from the very beginning, to not be tied to libxml2, but then it seemed rather tricky. Now rewriting/duplicating some sources in Rust (to optionally use those over C ones), and bringing libxml2 there seems even more awkward, with Rust having its own parsers and writers -- so it seems to be the time to introduce a custom structure.

  17. Link Mauve

    defanor, are you aware of the xmpp-parsers crate?

  18. Link Mauve

    It currently goes through an intermediate XML representation, but ultimately I want it to go directly from rxml (a SAX-like crate) to its internal structures.

  19. Link Mauve

    And back.

  20. defanor

    Link Mauve, I saw it as a dependency of xmpp-rs, was going to check it out once will get to working with XML in Rust. Though will check its structures now as well, thanks.

  21. jonas’

    as we're shilling, I made https://docs.rs/rxml/latest/rxml/ which is a streaming XML parser, which may or may not be useful to you

  22. defanor

    Haven't found that one while briefly looking at general Rust XML libraries recently, thanks for the link. Wrote it down and will look into those more closely once will reach the point of parsing and writing XML in Rust.