happymapper icon indicating copy to clipboard operation
happymapper copied to clipboard

Register Namespace Ordering

Open billy1kaplan opened this issue 3 years ago • 2 comments

I am dealing with a very fickle XML parser that requires the XML namespaces to be registered in a certain order.

For example, this passes:

<Root xmlns:ns1="..." xmlns:ns2="...">
</Root>

While this fails:

<Root xmlns:ns2="..." xmlns:ns1="...">
</Root>

Would it be possible to output the namespaces in the order that they were registered?

billy1kaplan avatar Feb 06 '23 23:02 billy1kaplan

Looking at the code: https://github.com/mvz/happymapper/blob/a650cecc262c0afcd8012cd5da1665e076abd4da/lib/happymapper.rb#LL92C33-L92C33

This might be as simple as changing:

@registered_namespaces.merge!(name => href)

to

@registered_namespaces[name] = href

billy1kaplan avatar Feb 06 '23 23:02 billy1kaplan

Yes, it makes sense to allow more control over this.

mvz avatar Feb 07 '23 09:02 mvz