xmlutil
xmlutil copied to clipboard
0.90.2: Could not find field for name when nested child is named like root
nl.adaptivity.xmlutil.serialization.UnknownXmlFieldException: Could not find a field for name (Testing.FooOperation) {http://foo.com/}operation/{http://bar.com/}operation (Element)
candidates: {http://foo.com/}name (Attribute), {http://bar.com/}output (Element), {http://bar.com/}input (Element), {http://foo.com/}operation (Element) at position 3:39
@Test
fun a() {
// language=xml
val x = """<?xml version="1.0" encoding="UTF-8" ?>
<foo:operation name="FooOperation" xmlns:foo="http://foo.com/" xmlns:bar="http://bar.com/">
<bar:operation name="BarOperation"/>
<foo:input name="FooInput"/>
<foo:output name="FooOutput"/>
</foo:operation>
"""
XML.decodeFromString(FooOperation.serializer(), x)
}
@Serializable
@XmlSerialName("operation", "http://foo.com/")
private data class FooOperation(
@XmlElement(false)
@XmlSerialName("name", "http://foo.com/")
val name: String,
@XmlElement
@XmlSerialName("operation", "http://bar.com/")
val operation: BarOperation,
@XmlElement
@XmlSerialName("input", "http://foo.com/")
val input: FooInput,
@XmlElement
@XmlSerialName("output", "http://foo.com/")
val output: FooOutput,
)
@Serializable
private data class BarOperation(
@XmlSerialName("name", "http://bar.com/")
val name: String
)
@Serializable
private data class FooInput(
@XmlSerialName("name", "http://foo.com/")
val name: String
)
@Serializable
private data class FooOutput(
@XmlSerialName("name", "http://foo.com/")
val name: String
)
Version: xmlutil: 0.90.2 serialization: 1.7.3 Kotlin: 2.0.21 (JVM)
I'll have a look. It somehow doesn't get the correct namespace for from the descriptors for the bar operation.
Please have a look with version 0.90.3. There was a bug with handling multiple namespaces as children of a single parent.
Thanks, it does work now!
The same underlying issue as #249