| Author |
Java validation error
|
Vasant Chandra
Greenhorn
Joined: Oct 06, 2012
Posts: 10
|
|
Hello All,
I have developed one java code which will do the validation of XML file against its XSD.
XSD validation is working fine but when i am trying to display the output (using code lines Newpayload = sb.toString(); System.out.println (Newpayload);), I am gettting
sax exception :Premature end of file.
Request you to please let me know what needs to be done to resolve the exception.
Regards!!
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 919
|
|
Hi Vasant,
We have a separate XML Forum where I think your question will be better answered. I am moving this post to that forum.
|
Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
|
 |
Ranganathan Kaliyur Mannar
Bartender
Joined: Oct 16, 2003
Posts: 919
|
|
Can you provide more information about the exception?
You have just given the exception message. If you can post the stack trace, that will have the information about the exact line number where the issue occurs. And that might help us to get more insight into the issue.
|
 |
Vasant Chandra
Greenhorn
Joined: Oct 06, 2012
Posts: 10
|
|
Ranganathan Kaliyur Mannar wrote:Can you provide more information about the exception?
You have just given the exception message. If you can post the stack trace, that will have the information about the exact line number where the issue occurs. And that might help us to get more insight into the issue.
Hello,
I am getting error at this step: validator.validate(new StreamSource(in));
Regards!!
|
 |
g tsuji
Ranch Hand
Joined: Jan 18, 2011
Posts: 359
|
|
I am gettting sax exception :Premature end of file.
and
I am getting error at this step: validator.validate(new StreamSource(in));
I bet you've some processing using the input stream in, actually used it in the way from its start to its end, between these two lines: line #14 and line #17 (the line establishing the schema1 is irrelevant to this observation).
Note that in that case, you have either to reload the "in" or you use FileChannel to "re-setting" the pointer to start of the stream "in". Use reload is the simplest. You'll find that if you've got passed the .validate() line, the following block suffers the same problem as after .validate(), the stream actually closed and you can't even do a re-pointing. In the latter case, only a reloading the xml to "in" is viable.
|
 |
Vinod Tiwari
Ranch Hand
Joined: Feb 06, 2008
Posts: 458
|
|
|
Can you post complete exception trace? However in meantime you may refer this link.
|
Vinod Tiwari | Twitter
|
 |
 |
|
|
subject: Java validation error
|
|
|