Open shevek opened 7 years ago
Do you mean empty value for list itself, or for element within list? Former would perhaps make sense; latter less so. I assume it is former.
I'm not entirely out of my depth here, but I'm heading that way, hence the very concrete example. My objective is just to deserialize that file, so any workaround which does so will be gratefully received. Fundamentally:
<outer>
</outer>
annotated as
@XmlElementWrapper("outer")
@XmlElement("inner")
List<Inner> inner;
doesn't deserialize, and I want it to. I had a bunch of related issues when I did have inner elements, like Jackson reporting an error message for an Inner field as missing on the element enclosing Outer, and so forth - if we get past this stage and I re-hit that, I'll put up another test case.
Ok, yes, that makes sense. I was referring to potential alternate case of
<outer>
<inner>
</inner>
</outer>
which would not be similarly possible to handle by ignoring it (although there's separate question of what should become of it -- just can not ignore such element of collection). Thank you for clarifying the case.
The larger case was:
<root>
<outer>
<inner name="value">
</outer>
</root>
And Jackson was reporting 'name' as a missing property on outer
, rather than instantiating it on 'inner'. Cutting that example down got me here, and if we get past this, I will reinstate that larger example, and submit it to you.
If it were possible to override XmlFactory._initializeXmlReader
then I could:
return _xmlInputFactory.createFilteredReader(r,
new StreamFilter() {
@Override
public boolean accept(XMLStreamReader r) {
return !r.isWhiteSpace();
}
});
but I can't because it's final. But if there were some way to inject this wrapper, then it would make the test pass.
Actually, that workaround only makes the smaller test pass. Now I'm back to the bug where it's mis-reporting and mis-applying the location of a field. I'll make up another example.
I've updated the github repository; if you pull, you will now find one instance of each failure. Really, it's the second that's killing me. Thank you!
In my production code, I added SimpleXML ( http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php ) annotations to all the beans, and it loads fine, so I'm a bit less stressed than I was earlier, and I've proved that my model is good for the XML. So now it's just a question of whether we can make Jackson do it.
Project moved, need to re-file at:
https://github.com/FasterXML/jackson-modules-base/issues
@shevek Do you think you could re-create with up-to-date description, based on your understanding of the state? Can add link back to this issue (for additional discussion).
I'm having exactly the same problem. I'm not using any JAXB annotations (neither did @shevek afaict), only jackson-module-xml
, so this should probably be reported there?
Btw. the workaround in the StackOverflow post worked for me.
To reproduce: git clone git@github.com:shevek/bugs-tests-and-examples.git git checkout jackson-xml-whitespace ./gradlew installDist && ./build/install/bugs-tests-and-examples/bin/bugs-tests-and-examples
Actual behaviour:
Variants of expected behaviour: When tweaking the XML file a bit:
Expected behaviour: Ignores whitespace in empty list element and does not attempt to synthesize a value out of it.
Related issues:
34
Thank you.