In an attempt to model some XML resembling
<outer>
Hello, world!
<inner>This is some mixed content!</inner>
Here's some more text!
</outer>
Where the text and inner can be in any arbitrary order, of zero or more items.
I have created a class hierarchy that looks like
@Serializable
data class Outer(
@XmlValue
val content: List<Content>
) {
@Serializable
sealed interface Content;
@Serializable
value class Text(val content: String): Content
@Serializable
data class Inner(
@XmlValue
val innerContent: String
): Content
}
However, the serializer spits back `Invalid XML value at position: 11:30: Serializer for subclass 'kotlin.String' is not found in the polymorphic scope of 'Content'.
Based on https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/value-classes.md, I would expect the value class to be "flattened" into a String automatically, but it seems like this is not happening? I'm no expert in XML in general, so maybe I've missed something?
In an attempt to model some XML resembling
Where the text and
innercan be in any arbitrary order, of zero or more items.I have created a class hierarchy that looks like
However, the serializer spits back `Invalid XML value at position: 11:30: Serializer for subclass 'kotlin.String' is not found in the polymorphic scope of 'Content'.
Based on https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/value-classes.md, I would expect the
value classto be "flattened" into a String automatically, but it seems like this is not happening? I'm no expert in XML in general, so maybe I've missed something?