Consider the XML:
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...
Consider the XML:
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
ais changed tob), 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:
<a:A xmlns:a="..."><a:B/></a:A>, then there's no need to repeat the namespace URL ofaforB, but a trivial implementation probably will.<a:A xmlns:a="..."><b:B xmlns:b="..."><a:C/></b:B></a:A>, then the namespace URL ofamust be repeated forC. 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.<a:A xmlns:a="..."><B/></a:A>should be transformed such thatBcontains"@xmlns": "".Will do this myself at some point if I find time...