-
Hi. I just switched from version 0.86.2 -> 0.86.3 now I am facing the problem that I need to define empty namespaces in my data class.
This is my Dataclass:
With version 0.86.2 this worked fine.
If I add the namespace to my data class I get following Exception:
Could somebody tell me what changed in the new version and if there is a way to ignore namespaces during deserialization? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The issue is with the way that namespace inheritance works. In other words, it tries to make a guess, and there was a problem with the guessing. Also, for the root element only, it will use whatever name the element actually has in the document rather than the one declared on the type. The following DTO should work (And yes, this is a poorly designed format): @Serializable
@XmlSerialName("salesLimit", "http://someNamespace", "ns1")
data class SaldoSalesLimitDto(
@XmlElement
@XmlSerialName("quantitySalesLimit", "", "")
val quantitySalesLimit: Int,
@XmlElement
@XmlSerialName("productId", "", "")
val productID: String,
@XmlElement
@XmlSerialName("outletId", "", "")
val outletId: String,
@XmlElement
@XmlSerialName("distributionChannel", "", "")
val distributionChannel: SalesLine,
@XmlElement
@XmlSerialName("subsidiary", "", "")
val subsidiary: Country,
) |
Beta Was this translation helpful? Give feedback.
The issue is with the way that namespace inheritance works. In other words, it tries to make a guess, and there was a problem with the guessing. Also, for the root element only, it will use whatever name the element actually has in the document rather than the one declared on the type.
Another factor to consider is that the default parameter values for
@XmlSerialName
are interpreted as automatic prefix/namespace rather than empty. Given your data your DTO is actually incorrect in that you need to set the namespace (and thusXmlSerialName
on all members). The current DTO rather relies on compatibility logic (it has no namespace, but is parsed as if it has a namespace - it should have a nam…