-
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
-
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?
-
jjj333_p (any pronouns)
okay referencing the body stanza at all causes a segfault?
-
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
-
singpolyma
I recursively call get_attaibutes and get_name down the tree and haven't seen this
-
singpolyma
Oh looks like I don't expect attribute length to be multiple of 2
-
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);
-
singpolyma
(excuse the syntax but I think you can see the idea of how I'm calling the C)
-
lovetox
XML question, is this equivalent <Tag xmlns="namespace" myattr="attr"> <pre:Tag xmlns:pre="namespace" pre:myattr="attr">
-
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
-
singpolyma
Nope. Attribute does not have the namespace of the element and the second is a very different thing
-
singpolyma
Attribute is logically namespaced by the element itself, *not* by the namespace of the element.
-
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
-
singpolyma
For example <pre:Tag attr="" pre:attr=""> is valid and those are two different attributes not a duplicate
-
moparisthebest
I find it helps to think of the least intuitive way you think attributes could possibly work, and that's how they work
-
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.
-
singpolyma
I mean it's pretty intuitive I think but it is different from elements which I know confuses some
-
lovetox
so if we look at this example which you defined for link metadata
-
lovetox
https://wiki.soprani.ca/CheogramApp/LinkPreviews
-
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">
-
lovetox
does it have a purpose to prefix the "about" attribute here
-
lovetox
for me it would have the same meaning if it would have no prefix
-
singpolyma
Yes it is required to prefix the attribute
-
lovetox
why?
-
singpolyma
Without the prefix would have a different meaning
-
singpolyma
It would be a different attribute and not the one the spec requires
-
lovetox
the attribute would still belong to its Element Description, and as it has the same namespace ..
-
lovetox
i would understand it, if we include a second about attribute maybe, but if there is only one ..
-
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?
-
lovetox
so the spec author could have decided to include it without defined namespace, and everything would work the same?
-
lovetox
i guess thats what it must be, its just a decision from the spec author to set a attr for the namespace✎ -
lovetox
i guess thats what it must be, its just a decision from the spec author to define the ns for the attr ✏
-
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#"
-
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
-
moparisthebest
that said... implementations with bugs exist that will fail in fun ways, good luck
-
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 ↺
-
lovetox
you expect attributes to behave like the elements, with similiar rules regarding namespaces, but they do not
-
lovetox
its not intuitive, but i guess if someone describes it good, and you learn it once, then its fine
-
moparisthebest
yep, it's just easy to work with XML for years and not know this, seemingly because namespaced attributes are rare
-
lovetox
yes correct, i worked with 10 years with XML, and now it was the first time it came up
-
moparisthebest
same for me a few months ago 💀
-
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