Skip to content

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

@HiQ-wipa

Description

@HiQ-wipa

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions