This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XmlBeans validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XmlBeans validation" Watch "XmlBeans validation" New topic
Author

XmlBeans validation

RabindraBlr Sahoo
Greenhorn

Joined: Nov 04, 2008
Posts: 7
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If that's your requirement, then your next step is to re-parse the document without validation.
Amer Seifeddine
Ranch Hand

Joined: Apr 25, 2002
Posts: 57
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

Joined: Nov 04, 2008
Posts: 7
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Nov 04, 2008
Posts: 7
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XmlBeans validation
 
Similar Threads
Alternatives To Castor
how to validate xml using local xsd
PayloadValidatingInterceptor - spring-ws-1.5
Checking XSD constraints at runtime
Axis 2 problems