-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@XStreamInclude doesn't ignore tags #66
Comments
Hi, the ignoreUnknownElements flag is only supported for members of a class, not for items of a collection/array/map. The converters handling these types have much less control over their items than the reflection based converters knowing exactly allowed field names and their types. |
Okay. Whats the suggested solution for ignoring collection/array/map items? |
Well, first I'd like to know, why do you expect elements in the list you do not know? If they are elements, you do no longer support, then add a dummy class, add an alias for the "unknown" element name and add a converter that return such a dummy instance (or null - depends on your use case). You may later process the result and drop these elements from the collection. If you want to protect from manipulation of the XML, this will not really help, because someone is always able to add arbitrary elements to the list that are valid ... at least for XStream: <tags>
<tag1></tag1>
<tag2></tag2>
<string>fake an element in tags</string>
</tags> |
I can't control the XML (i read them from a webservice and they can add new list tags every moment) and don't want XStream to fail if there are additional elements. The |
There's no general solution for all these collection types with the current release. Your best option is to derive from the CollectionConverter and to overload the addCurrentElementToCollection method. Catch the exception thrown when calling readItem and return immediately then. |
Okay, thank you. |
Hi,
I'm using XStream with
ignoreUnknownElements()
enabled. I'm trying to parseSo far, so good. If i add
<tag3></tag3>
to the<tags>
list but not to the@XStreamInclude
, i assumed XStream will ignore that element. Instead it raises an exception:I've written a reproducer: https://github.com/phxql/xstreaminclude-reproducer
Is there a way to ignore unknown tags in a list?
The text was updated successfully, but these errors were encountered: