redpanda-data / redpanda-data/connect

The XML processor omits namespaces

Open
#3,928 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.