• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XmlBeans validation

 
RabindraBlr Sahoo
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
 
Paul Clapham
Sheriff
Posts: 21322
32
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.
 
Amer Seifeddine
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
Sheriff
Posts: 21322
32
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic