Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

XmlBeans validation

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am validating an xml with schema(.xsd) using xmlbeans provided by apache and it returns the errorlist correctly after validation.
But my requirement is to skip the unwanted tag and proceed for parsing.
Please let me how to achieve this?

Thanks in Advance!!!

Regards,
Rabindra
 
Marshal
Posts: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that's your requirement, then your next step is to re-parse the document without validation.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

You have the option to skip the validation from the class as option or using the command line.. If you are using a class to generate your schema:

XmlOptions opts = new XmlOptions();
opts.setCompileNoValidation();

Otherwise, skip the validation using the scomp option.

Hope this helps.
 
RabindraBlr Sahoo
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amer,

Thanks for your valuable response!
By using setCompileNoValidation(), it will not validate the xml against the schema at all.
But i need to validate only the mandatory/optional tags and skip the unwanted tags. Is there any option in XmlOptions to achieve this?

Thanks in Advance:)
Thanks,
Rabindra
 
Paul Clapham
Marshal
Posts: 25795
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by RabindraBlr Sahoo:
But i need to validate only the mandatory/optional tags and skip the unwanted tags.

Then create a new schema which does the validations you really want. Trying to use a schema which doesn't validate the way you want and hoping the parser will clean up the resulting mess isn't a good idea. (I assume that "skip the unwanted tags" means "don't validate them". If it means that the parser should discard them and treat the rest of the document as valid, you can't do that.)
 
RabindraBlr Sahoo
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!!!

Is there any option to achive this in the schema(.xsd) itself?

i.e. <xs:any minOccurs="0"/>
However the unwanted tag may come at any sequence and it may be simpletype or complextype. Then i need to decalre <any> tag in each and every position as complex and simpletype.

Is there any simple way to do this

Thanks in advance.

Cheers
Rabindra
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic