jxon icon indicating copy to clipboard operation
jxon copied to clipboard

Namespace prefix removed with jsToString in browsers

Open nrenner opened this issue 4 years ago • 0 comments

When the following JavaScript object, with a custom namespace xmlns:locus defined in the root element and some nested element prefixed with locus:, is serialized to a XML string with jsToString, the prefix gets removed in the browser:

See demo

JS input

{
    "gpx": {
        "$xmlns": "http://www.topografix.com/GPX/1/1",
        "$xmlns:locus": "http://www.locusmap.eu",
        "trk": {
            "extensions": {
                "locus:rteComputeType": "5"
            }
        }
    }
}

XML output

<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:locus="http://www.locusmap.eu">
  <trk>
    <extensions>
      <rteComputeType>5</rteComputeType>
    </extensions>
  </trk>
</gpx>

expected

      <locus:rteComputeType>5</locus:rteComputeType>

actual

      <rteComputeType>5</rteComputeType>

nrenner avatar Mar 04 '21 18:03 nrenner