This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML and java beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML and java beans" Watch "XML and java beans" New topic
Author

XML and java beans

druva singh
Greenhorn

Joined: Feb 13, 2009
Posts: 3
Hi,
I am using the JOX library to convert my XML file to java objects.
I need to validate this XML file before this object conversion takes place. Doing this with javax.xml.validation

Catch here is-
if there is a erroneous tag it needs to be overlooked as incomplete and not be converted to an object BUT BE SKIPPED. Other valid tags must be converted to objects

e.g. XML where id, name tags are both compulsory


<id>1
<name> abc
<address> abc-addr

<id>2
<name> pqr

<id>3

So, object with id = 3 must not be created but other objects must..

Any help would be appreciated!

Thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Nope. XML parsers aren't allowed to "fix" incorrect data, they are required to terminate when they reach the first error.

But you have well-formed XML, don't you? So you could write your own code to remove data which you deem to be incorrect.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML and java beans
 
Similar Threads
Struts2 POJO population from URL
xml to java objects
K &B String Doubt
Facade design pattern in web services
convert javaobjects to xml and xml to java objects dynamically