xmlutil icon indicating copy to clipboard operation
xmlutil copied to clipboard

0.90.2: Could not find field for name when nested child is named like root

Open hfhbd opened this issue 1 year ago • 1 comments

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)

hfhbd avatar Oct 16 '24 10:10 hfhbd

I'll have a look. It somehow doesn't get the correct namespace for from the descriptors for the bar operation.

pdvrieze avatar Oct 17 '24 11:10 pdvrieze

Please have a look with version 0.90.3. There was a bug with handling multiple namespaces as children of a single parent.

pdvrieze avatar Nov 07 '24 12:11 pdvrieze

Thanks, it does work now!

hfhbd avatar Nov 07 '24 12:11 hfhbd

The same underlying issue as #249

pdvrieze avatar Nov 07 '24 18:11 pdvrieze