jackson-dataformat-xml icon indicating copy to clipboard operation
jackson-dataformat-xml copied to clipboard

Simillar elements inside are skipped

Open aivanovski opened this issue 2 years ago • 5 comments

XmlMapper just skips elements inside element with resource-id="com.ivanovsky.passnotes:id/recyclerView". File is attached. There is also no warnings, errors or any kind messages after XmlMapper().readValue() call.

version 2.15.2

groups-screen-invalid-dump.xml.txt

aivanovski avatar Sep 16 '23 15:09 aivanovski

@aivanovski This explanation is not sufficient to understand what your problem is -- please include code you are using, with expectations of what you thing should happen. Ideally in a form of a test case. As is, I don't know what "Similar" here means, for example, nor why you think an expection ought to be thrown (Jackson does not use logging so no warnings would ever result).

cowtowncoder avatar Sep 19 '23 04:09 cowtowncoder

Some elements inside XML file aren't parsed, they are skipped during XmlMapper().readValue() call. These skipped elements are located inside element with resource-id="com.ivanovsky.passnotes:id/recyclerView" where resource-id is an XML attribute inside one of XML elements of the attached XML file. @cowtowncoder

aivanovski avatar Sep 21 '23 20:09 aivanovski

Some elements inside XML file aren't parsed, they are skipped during XmlMapper().readValue() call. These skipped elements are located inside element with resource-id="com.ivanovsky.passnotes:id/recyclerView" where resource-id is an XML attribute inside one of XML elements of the attached XML file. @cowtowncoder

@aivanovski you haven't provided a meaningful example. There is no need to keep posting the same sparse details - they are not sufficient.

pjfanning avatar Sep 21 '23 20:09 pjfanning

I supposed you guys at least try to parse attached file, but ok, that's honest enough. It's Kotlin. Inside the deserilized result (data variable), there is a node with resourceId=com.ivanovsky.passnotes:id/recyclerView it doesn't have a children, but xml file has children.

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonRootName
import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
import com.fasterxml.jackson.dataformat.xml.XmlMapper
import java.io.File

fun main(args: Array<String>) {
    val data = XmlMapper(JacksonXmlModule())
        .readValue(
            File("groups-screen-invalid-dump.xml.txt"),
            Hierarchy::class.java
        )
}

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("node")
class Node {
    @set:JsonProperty("resource-id", required = false)
    var resourceId: String? = null

    @set:JsonProperty("text", required = false)
    var text: String? = null

    @set:JsonProperty("node", required = false)
    var nodes: List<Node> = mutableListOf()
}

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("hierarchy")
class Hierarchy {
    @set:JsonProperty("rotation", required = false)
    var rotation: Int? = null

    @set:JsonProperty("node", required = false)
    var nodes: List<Node> = mutableListOf()
}

aivanovski avatar Sep 21 '23 21:09 aivanovski

Java code also has the same issue. JacksonTestJava.java.txt

aivanovski avatar Sep 21 '23 21:09 aivanovski