question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Namespace null does not match expected ""

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pdvriezecommented, Mar 20, 2020

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).

0reactions
pdvriezecommented, May 17, 2020

Should now work again in 0.20.0.1

Read more comments on GitHub >

github_iconTop 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 >
F# coding conventions
Learn general guidelines and idioms when writing F# code.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found