[xsd-users] Ignoring unknown elements

Boris Kolpackov boris at codesynthesis.com
Wed Apr 4 06:45:15 EDT 2018


Henry Dornemann <henry at commvault.com> writes:

> Is there some way to ignore unknown elements while parsing an XML document?
>
> The situation that I have is the xsd schema file is provided by a 3rd party
> and I utilize xsd to generate code to parse this. The 3rd party will extend
> their schema with new versions and this breaks our ability to parse the
> documents even though I only care about the already known elements and not
> the new elements that are added in the new version.
> 
> What's worse here is that this condition doesn't even generate a parsing
> error, we just get a partially populated object and don't even realize
> that there was something wrong with the input document

You would have gotten a validation error (against schema that you have
used to generate the code) if you haven't disabled it. In other words,
if you disable validation and feed invalid XML, pretty much all bets
are off.


> I found a previous question on this same topic
> https://www.codesynthesis.com/pipermail/xsd-users/2014-October/004453.html
> but I don't see any resolution from it; was any command line option
> added to avoid breaking out of the element parsing loop?

Unfortunately, there is no auto-magic resolution other than what's
suggested in that email (either use wildcards or pre-filter the DOM).
Specifically, not breaking out of the loop will break support for
inheritance.

Boris



More information about the xsd-users mailing list