Closed mincong-h closed 2 years ago
Correct: Jackson XML module does not allow elements or attributes that only differ by namespace (prefixes map to namespaces in XML). This is a limitation that exists currently and there are no current plans to change this behavior -- theoretically it could be fixed, of course, as Jackson does keep track of declared namespace. But only local name is currently used for matching properties.
There are existing issues for this, for example #27, #65 and #192 so I will close this as duplicate.
Thanks for your quick reply @cowtowncoder , really appreciate that. Your explanation is very clear. 👍 By the way, I ended up using jsoup as the replacement and relying on CSS selector to find the right tag (content
or media:content
).
@mincong-h thank you -- and apologies for having to go through the workaround. Ideally it really should "just work". But I am glad you were able to find a workaround.
Currently if there are two elements with the same name, one with prefix and the other without prefix, Jackson XML mapper cannot read them correctly. For example, in the following structure, mapper fails to recognize the "media:content" properly:
I discovered this when trying to read the feed (RSS) of my blog (https://mincong.io/feed.xml). The XML structure is generated by Jekyll Feed plugin (source code), where both
content
andmedia:content
exist, so I don't want to modify them if possible. I am using Jackson XML in version 2.13.2.Here is the test suite to reproduce the problem, where the 2nd test fails with content as empty string: