FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
561 stars 221 forks source link

Deserialization into collection does not respect namespaces #649

Closed GithubUser8080 closed 3 months ago

GithubUser8080 commented 3 months ago

When using

public class MyProps {
  @JsonAnySetter
  public Map<String, Object> props;
}

On a POJO, with the intent to have a schema where can contain any amount of unknown child elements

Deserializing XML such as

<MyProps xmlns:schema1="http://....schema1" xmlns:schema2="http://....schema2">
     <schema1:child/>
     <schema2:child/>
<MyProps>

Results in the map containing only 1 object named "child". As per XML these are two different elements, so how would it be possible to map according to both namespace and attribute name?

cowtowncoder commented 3 months ago

Namespace information is currently not really used or retained on deserialization at all: it is produced on serialization for compatibility purposes.

So there is no way to map by namespace URI at this point, nor immediate plans to support it. Similarly whether something comes as an Attribute or Element is not retained either.

GithubUser8080 commented 3 months ago

Ok, so just to be clear, there is nothing equivalent in jackson to JAXB @XMLAnyElement where i can map unknown child elements to an Element object list and then get the namespace instead of just strings with their name?

cowtowncoder commented 3 months ago

@GithubUser8080 correct.

GithubUser8080 commented 3 months ago

Got it, thank you. I will close the issue.