aspose file tools*
The moose likes XML and Related Technologies and the fly likes Java validation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Java validation error" Watch "Java validation error" New topic
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: 1089
    
  10

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: 1089
    
  10

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: 541
    
    3
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: 466
    
    1

Can you post complete exception trace? However in meantime you may refer this link.


Vinod Tiwari | Twitter | Shikshanirman | Guftgu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java validation error