Skip to content

Preserve reference order in generated XML encoders - #53

Merged
badlop merged 2 commits into
processone:masterfrom
rallep71:fix/preserve-reference-order
Aug 27, 2026
Merged

Preserve reference order in generated XML encoders#53
badlop merged 2 commits into
processone:masterfrom
rallep71:fix/preserve-reference-order

Conversation

@rallep71

Copy link
Copy Markdown
Contributor

While testing SASL2, I found that generated encoders can emit groups of child
elements in a different order from the one declared in the codec
specification.

group_refs/1 currently stores the groups in a dict and returns them with
dict:to_list/1. That does not preserve their order in #elem.refs. The
encoder then builds an accumulator which is reversed before output, so the
resulting sibling order depends on the dictionary ordering.

This change records the first occurrence of each group while keeping the
existing grouping behaviour. It also folds the groups in the direction needed
by the final accumulator reversal.

The XML-RPC codec has been regenerated, and the regression test uses a small
codec with two mechanism children followed by inline. Before the fix it is
serialised as inline, mechanism, mechanism; with the fix the declared order
is retained.

Related to processone/ejabberd#4606.

Tests

  • Confirmed that the new test fails against 1.1.60 and passes with this change
  • rebar3 eunit -v — 86 tests passed on Erlang/OTP 28
  • rebar3 xref
  • REBAR=rebar3 make spec

@p1bot

p1bot commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Hi @rallep71, many thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes.

@rallep71
rallep71 force-pushed the fix/preserve-reference-order branch from e0fca27 to 5e5e10f Compare August 27, 2026 11:45
@p1bot

p1bot commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

You did it @rallep71!

Thank you for signing the ProcessOne Contribution License Agreement.

We will have a look at your contribution!

@p1bot p1bot removed the cla-missing Contributor needs to sign Contribution License Agreement label Aug 27, 2026
@badlop
badlop merged commit ee0e656 into processone:master Aug 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants