It’s similar to P1’s implementation, in that it will pattern match the head of 
the child element list and pop a known child off and parse it. It’s a common 
approach in functional languages.

https://github.com/processone/xmpp/blob/master/src/xep0004.erl#L152

Not sure how we’ll do it on the client yet.

- Drew

> On Feb 14, 2021, at 3:17 PM, Florian Schmaus <f...@geekplace.eu> wrote:
> 
> On 2/11/21 7:09 PM, Drew Varner wrote:
>> First time caller, long time listener.
>> Some model-driven CODECs may not enforce nor detect order.
>> P1’s model-based XMPP CODEC (https://github.com/processone/xmpp) does not 
>> enforce nor care about the order of the elements.
>> ```
>> 2> ReportedFirst = <<"<x xmlns='jabber:x:data' 
>> type='result'><reported><field var='field-name-one' label='description' 
>> type='text-single'/></reported><item><field 
>> var='field-name-two'><value>field-value</value></field></item><item><field 
>> var='field-name-three'><value>field-value</value></field></item></x>">>.
>> <<"<x xmlns='jabber:x:data' type='result'><reported><field 
>> var='field-name-one' label='description' type='text-single'/"...>>
>> 3> ReportedLast = <<"<x xmlns='jabber:x:data' type='result'><item><field 
>> var='field-name-two'><value>field-value</value></field></item><item><field 
>> var='field-name-three'><value>field-value</value></field></item><reported><field
>>  var='field-name-one' label='description' 
>> type='text-single'/></reported></x>">>.
>> <<"<x xmlns='jabber:x:data' type='result'><item><field 
>> var='field-name-two'><value>field-value</value></field></item><i"...>>
>> 4> xmpp:decode(fxml_stream:parse_element(ReportedFirst)) == 
>> xmpp:decode(fxml_stream:parse_element(ReportedLast)).
>> true
>> ```
>> There’s no way for them to detect the invalid order in the server code, 
>> because the CODEC hands them a record/struct. They do write it in the 
>> correct order because their implementation happened to use lists to element 
>> refs instead of maps.
> 
> What about the reading side: How does your CODEC assign field types to fields 
> of incoming data forms?
> 
> - Florian
> 
> 
> _______________________________________________
> Standards mailing list
> Info: https://mail.jabber.org/mailman/listinfo/standards
> Unsubscribe: standards-unsubscr...@xmpp.org
> _______________________________________________
_______________________________________________
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
_______________________________________________

Reply via email to