In my Java (Maven) project I'm using JAXB 2.2.11 to rebuild instances of a class from an XML payload received by our servers. I have an .xsd
schema defining the class, which works great in conjunction with JAXB to rebuild an instance of the type I want. The issue I'm having is that those payloads can (without any notice or warning) have extra elements which I don't really care about.
One of the places where those extra elements can appear is within an xs:all
tag. I do like having the functionality of said xs:all
tag:
The all element specifies that the child elements can appear in any order and that each child element can occur zero or one time.
However, I don't want to get a parsing error while processing an XML payload that contains extra attributes. An xs:any
tag inside the xs:all
would work great, but it's not permitted in XSD 1.0 (according to w3schools and this other SO answer) and apparently, JAXB doesn't support XSD 1.1. Also, the way JAXB
treats the any
or the anyAttribute
is very interesting, because it puts all the unknown nodes into a map, so I can log it saying "Hey! We are receiving an attribute that we don't really care about as of now, but maybe you'll find it somehow useful in the future?"
I've read about Xsom, that supports XSD 1.1, but apparently, it doesn't return an instance of the class you want, but more generic set of hash-maps and lists, therefore losing my type checking, which is something I don't want to.
So... Is there any way of pretending to have an xs:any
within an xs:all
?