• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java validation error

 
Vasant Chandra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 466
1
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post complete exception trace? However in meantime you may refer this link.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic