Skip to content

Unable to deserialise CompactFragment annotated with @XmlValue #269

@JR-Mitchell

Description

@JR-Mitchell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingindevThe issue is fixed/implemented in the dev branch

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions