jdev - 2025-10-10


  1. jjj333_p (any pronouns)

    any idea why with libstrophe, if i call xmpp_stanza_get_attribute_count() on the stanza object for the body child element, it returns 1? my understanding is if you get a nonzero number you expect 2x that many elements of xmpp_stanza_get_attributes() but iterating that far from the pointer causes a segfault

  2. jjj333_p (any pronouns)

    i mean i suppose i could for now just if name is body not try to get atributes, but maybe im doing something else wrong?

  3. jjj333_p (any pronouns)

    okay referencing the body stanza at all causes a segfault?

  4. jjj333_p (any pronouns)

    well not "at all" since i can to the atribute count, but calling xmpp_stanza_get_name(stanza) causes a segfault

  5. singpolyma

    I recursively call get_attaibutes and get_name down the tree and haven't seen this

  6. singpolyma

    Oh looks like I don't expect attribute length to be multiple of 2

  7. singpolyma

    var attrlen = StropheStanza.get_attribute_count(el); var attrsraw: RawPointer<cpp.Void> = NativeGc.allocGcBytesRaw(attrlen * 2 * untyped __cpp__("sizeof(char*)"), false); var attrsarray: RawPointer<RawConstPointer<Char>> = untyped __cpp__("static_cast<const char**>(attrsraw)"); var attrsptr = cpp.Pointer.fromRaw(attrsarray); StropheStanza.get_attributes(el, attrsarray, attrlen * 2);

  8. singpolyma

    (excuse the syntax but I think you can see the idea of how I'm calling the C)

  9. lovetox

    XML question, is this equivalent <Tag xmlns="namespace" myattr="attr"> <pre:Tag xmlns:pre="namespace" pre:myattr="attr">

  10. lovetox

    hm its not strictly equivalent, in the first example myattr has no namespace, but by convention we interpret it as in the namespace of the element, in the second example it has an explicit namespace

  11. singpolyma

    Nope. Attribute does not have the namespace of the element and the second is a very different thing

  12. singpolyma

    Attribute is logically namespaced by the element itself, *not* by the namespace of the element.

  13. singpolyma

    So most attributes are treated as having "no namespace" unless they have an explicit one and an explicit one can never be equivalent to not having one

  14. singpolyma

    For example <pre:Tag attr="" pre:attr=""> is valid and those are two different attributes not a duplicate

  15. moparisthebest

    I find it helps to think of the least intuitive way you think attributes could possibly work, and that's how they work

  16. dwd

    Also, semantically, names paced attributes tend to have meaning independent from the element. So the "to" attribute of a message is different to that of a stream, but the general meaning of xml:lang is the same.

  17. singpolyma

    I mean it's pretty intuitive I think but it is different from elements which I know confuses some

  18. lovetox

    so if we look at this example which you defined for link metadata

  19. lovetox

    https://wiki.soprani.ca/CheogramApp/LinkPreviews

  20. lovetox

    <rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:og="https://ogp.me/ns#" rdf:about="https://the.link.example.com/what-was-linked-to">

  21. lovetox

    does it have a purpose to prefix the "about" attribute here

  22. lovetox

    for me it would have the same meaning if it would have no prefix

  23. singpolyma

    Yes it is required to prefix the attribute

  24. lovetox

    why?

  25. singpolyma

    Without the prefix would have a different meaning

  26. singpolyma

    It would be a different attribute and not the one the spec requires

  27. lovetox

    the attribute would still belong to its Element Description, and as it has the same namespace ..

  28. lovetox

    i would understand it, if we include a second about attribute maybe, but if there is only one ..

  29. lovetox

    or is this just a spec definition? the spec defines a attribute in a namespace, rather then leaving it undefined and just saying we should include a attribute in the element with undefined namespace?

  30. lovetox

    so the spec author could have decided to include it without defined namespace, and everything would work the same?

  31. lovetox

    i guess thats what it must be, its just a decision from the spec author to set a attr for the namespace

  32. lovetox

    i guess thats what it must be, its just a decision from the spec author to define the ns for the attr

  33. lovetox

    then follow up question, is the prefix itself defined in the spec, in this case "rdf", or could i receive messages where a client just says xmlns:abc="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

  34. moparisthebest

    Actual prefix itself is supposed to be meaningless, it could be 'aoeu' instead of 'rdf', with the single exception of 'stream' which must be stream for hysterical raisins

  35. moparisthebest

    that said... implementations with bugs exist that will fail in fun ways, good luck

  36. moparisthebest

    > the attribute would still belong to its Element Description, and as it has the same namespace .. that's the misunderstanding, which I also find totally unintuitive: (assume namespace rdf is defined above) 1: <rdf:bla rdf:about='foo'/> 2: <rdf:bla about='foo'/> For #1 the about attribute has the namespace rdf, for #2 it's got no namespace

  37. lovetox

    you expect attributes to behave like the elements, with similiar rules regarding namespaces, but they do not

  38. lovetox

    its not intuitive, but i guess if someone describes it good, and you learn it once, then its fine

  39. moparisthebest

    yep, it's just easy to work with XML for years and not know this, seemingly because namespaced attributes are rare

  40. lovetox

    yes correct, i worked with 10 years with XML, and now it was the first time it came up

  41. moparisthebest

    same for me a few months ago 💀

  42. dwd

    > yep, it's just easy to work with XML for years and not know this, seemingly because namespaced attributes are rare Well, aside from the fixed namespaced prefixes like xmlns and xml