redpanda-data / redpanda-data/connect
The XML processor omits namespaces
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 8.8k
- Forks
- 969
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 64
Description
Given an XML document with namespaces, the converted JSON via the XML processor lost namespace info:
<root xmlns:dc="http://my.namespace/dc" xmlns:ot="http://my.namespace/ot">
<dc:title>This is a title</dc:title>
<dc:description tone="boring">This is a description</dc:description>
<ot:elements id="1">foo1</ot:elements>
<ot:elements id="2">foo2</ot:elements>
<ot:elements>foo3</ot:elements>
</root>
yields:
{
"root":{
"title":"This is a title",
"description":{
"#text":"This is a description",
"-tone":"boring"
},
"elements":[
{"#text":"foo1","-id":"1"},
{"#text":"foo2","-id":"2"},
"foo3"
]
}
}
This is somewhat unfortunate since the original XML document cannot be reconstructed from the JSON output.
@mihaitodor told me on Discord that this is due to the current implementation some time ago (I assume encoding/xml), but I wanted to at least leave this issue in case something changes. Here is a related Stackoverflow question: https://stackoverflow.com/questions/79635707/encoding-xml-retaining-xml-namespace-prefixes-when-encoding-decoding . Maybe if the referenced feature https://go-review.googlesource.com/c/go/+/355353 gets merged in Go, an option could be added?
Thank you
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the XML processor and its use of Go's encoding/xml, then review the linked Go proposal about retaining namespace prefixes. Done means defining and implementing a feasible approach that preserves namespace information in the JSON output, with coverage for the namespaced XML example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- data-engineering, stream-processing
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100