Open joejensen8 opened 4 months ago
There are some issues, but it should work the following way:
autoPolymorphic = true
(or go with one of the recommended presets)nl.adaptivity.xmlutil.serialization.NodeSerializer
, so the best way to go is to use nl.adaptivity.xmlutil.dom2.Node
as type in the list (List<Node
). This works for me.List<@Polymorphic Any>
doesn't work as for that to work it would need to treat NodeSerializer/ElementSerializer special (I have some algorithm that works, for the next release, but it requires only a single non-primitive concrete polymorphic child)
I'm trying to parse XML for Android string files, here's an example:
NOTE - the XML value within each tag is unique in that it can contain nested values like the xliff:g tags shown.
In my example code below, I'm unable to unpack the value within the tags in any form to get it in its entirity.
Test file to debug
The line of focus above is
val node: List<@Polymorphic Any>
in theStringTag
data class.When it is
val node: List<@Polymorphic Any>
, I get this captured data model:The problem above is on the first item with 2 values (called "node"). It captures the strings before and after the
<xliff:g>
tag, but not that tag itself.When it is any of the following, I get the error below.
val node: List<Node>
val node: List<@Serializable(with = NodeSerializer::class) Node>
val node: Node
val element: Element
val element: List<Element>
val element: List<@Serializable(with = ElementSerializer::class) Element>
(all above usingorg.w3c.dom.Element
andimport org.w3c.dom.Node
)Perhaps I'm missing something, or doing something wrong entirely? I just want to parse the value within the
<string>
tag on an Android strings file, capturing all items within.