[xsd-users] Ignoring unknown elements

Henry Dornemann henry at commvault.com
Wed Apr 4 08:11:54 EDT 2018


Boris,

Could you elaborate further on the steps you are proposing here?  At a glance they seem rather involved, and that I'd essentially be parsing the XML myself, which would defeat the purpose of using xsd to generate the parsing code.

I don't quite understand why not breaking from the loop would break inheritance.  I can see each object calling it's parent parse method that has its own for loop parsing the elements.  Perhaps the derived parse picks up where the other method left off so it would miss out.  Couldn't the parse method be broken up to the for loop and a parseElement which would handle each element and could call up the class hierarchy looking for an object that recognizes each element? 

Do you consider what I am trying to do here an invalid use case for xsd?  

Thanks
-Henry



-----Original Message-----
From: Boris Kolpackov <boris at codesynthesis.com> 
Sent: Wednesday, April 4, 2018 6:45 AM
To: Henry Dornemann <henry at commvault.com>
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Ignoring unknown elements

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

***************************Legal Disclaimer***************************
"This communication may contain confidential and privileged material for the
sole use of the intended recipient. Any unauthorized review, use or distribution
by others is strictly prohibited. If you have received the message by mistake,
please advise the sender by reply email and delete the message. Thank you."
**********************************************************************




More information about the xsd-users mailing list