If we have some XML that looks something like:
<root attribute="value"><child>Hello</child><child>World!</child></root>
There may be use cases where we wish to partially decode this as a data class such as
@Serializable
@XmlSerialName("root")
data class Root(
val attribute: String,
@XmlValue val tagSoup: CompactFragment?
)
// Expected
Root(
attribute = "value",
tagSoup = CompactFragment("<child>Hello</child><child>World!</child>")
)
so that we can directly retrieve the nested tag soup as a raw string, whilst separately accessing the parsed attribute.
However, attempting to deserialise with this pattern throws nl.adaptivity.xmlutil.serialization.XmlSerialException: End document in unexpected location.
This can be successfully deserialised using List<CompactFragment>, however in that case there is no clear way to transform to/from a singular string for the list of compact fragments.
If we have some XML that looks something like:
There may be use cases where we wish to partially decode this as a data class such as
so that we can directly retrieve the nested tag soup as a raw string, whilst separately accessing the parsed attribute.
However, attempting to deserialise with this pattern throws
nl.adaptivity.xmlutil.serialization.XmlSerialException: End document in unexpected location.This can be successfully deserialised using
List<CompactFragment>, however in that case there is no clear way to transform to/from a singular string for the list of compact fragments.