Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Add option to remove namespace prefixes #26

Open
HiQ-wipa opened this issue Aug 11, 2024 · 0 comments
Open

[Feature request] Add option to remove namespace prefixes #26

HiQ-wipa opened this issue Aug 11, 2024 · 0 comments

Comments

@HiQ-wipa
Copy link

Consider the XML:

<a:A xmlns:a="foo.bar"/>

Currently, the task transforms this to:

{
	"a:A": {
		"@xmlns:a": "foo.bar"
	}
}

However, XML processing should be independent of the naming of namespaces (i.e. here the XML should be processed the same even if a is changed to b), which is extremely cumbersome with JSON.

I think there should be an input option to anonymize namespaces, such that the above is instead transformed to:

{
	"A": {
		"@xmlns": "foo.bar"
	}
}

Naturally, the anonymization should be applied recursively to inner elements.

Possible issues:

  • Repetition: If the input XML is <a:A xmlns:a="..."><a:B/></a:A>, then there's no need to repeat the namespace URL of a for B, but a trivial implementation probably will.
  • Repetition: If the input XML is <a:A xmlns:a="..."><b:B xmlns:b="..."><a:C/></b:B></a:A>, then the namespace URL of a must be repeated for C. This is quite uncommon, since namespaces are typically only used for wrapping. For example, SOAP envelopes use namespace "http://www.w3.org/2003/05/soap-envelope" and the same namespace is typically not used in the SOAP message content.
  • Empty namespaces should be handled correctly. For example, <a:A xmlns:a="..."><B/></a:A> should be transformed such that B contains "@xmlns": "".

Will do this myself at some point if I find time...

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

No branches or pull requests

1 participant