Namespace null does not match expected ""
See original GitHub issueHi,
not sure what I’m missing but after updating to kotlinx-serialization-runtime 0.20.0 and xmlutil-serialization-jvm 0.20.0.0 (from 0.14.0 and 0.14.0.2).
Following code:
@Serializable
@XmlSerialName(value = "metadata", namespace = "", prefix = "")
data class Metadata(
@XmlElement(true)
val groupId: String = "NONE",
@XmlElement(true)
val artifactId: String = "NONE",
@XmlElement(true)
val version: String = "NONE"
)
fun main() {
val response = """<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0.0-SNAPSHOT</version>
</metadata>"""
val xmlMapperX = XML {
indent = 4
}
println(xmlMapperX.parse(Metadata.serializer(), response))
}
Produces:
Exception in thread "main" nl.adaptivity.xmlutil.XmlException: Namespace null does not match expected ""
at nl.adaptivity.xmlutil.StAXReader.require(StAXReader.kt:113)
at nl.adaptivity.xmlutil.serialization.XmlDecoderBase$TagDecoder.endStructure(XMLDecoder.kt:748)
at com.test.Metadata$$serializer.deserialize(XmlTest.kt)
at com.test.Metadata$$serializer.deserialize(XmlTest.kt:11)
at nl.adaptivity.xmlutil.serialization.XmlDecoderBase$XmlDecoder.decodeSerializableValue(XMLDecoder.kt:140)
at nl.adaptivity.xmlutil.serialization.XML.parse(XML.kt:334)
at nl.adaptivity.xmlutil.serialization.XML.parse(XML.kt:352)
at com.test.XmlTestKt.main(XmlTest.kt:33)
at com.test.XmlTestKt.main(XmlTest.kt)
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Why is the 'null-namespace' expected for an xml element ...
Short answer: add elementFormDefault="qualified" to the root xs:schema tag of your schema. Longer answer: by default, only top-level ...
Read more >XML Schema: Understanding Namespaces
Moving to XML Schema? This introduction to namespaces will help you understand one of its more important elements.
Read more >Resolution of the validation error when a schema specifies ...
Create a third schema having a different target namespace, and importing the ... Validate the .xsd file: no error should be reported.
Read more >XML namespace issues - 8.0
A frequent problem when using namespaces is the XML element(s) are not read because their namespace does not match the expected namespace.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The workaround is using woodstox as stax runtime:
runtimeOnly("com.fasterxml.woodstox:woodstox-core:5.0.3")
. I’ve also pushed a fix to master that should work. Please have a look. I’ll try to push it tomorrow - I’ve been crazy buzy these last days moving all teaching online with 3 days preparation time (including getting to the office to pick up things before we’re not supposed to be in the office anymore).Should now work again in 0.20.0.1