• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Cator Parsing Exception

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A HAPPY NEW YEAR TO EVERYONE.

I am using Castor to parse the XML recieved as InputStream

The xsd used to generate the java classes are as follows:

[ dn_translation_result.xsd ]


[ enrichment_result.xsd ]

The XML recieved is :

The following code throws an exception as below:

where 'is' is the XML InputStream. I tried this with FileInputStream also, with same result.

Can anyone help me out in solving this issue?

Thanks
Surendran
[ January 01, 2006: Message edited by: Surendran Velath ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way to get that premature end of file message is if the stream is empty. How have you checked to be sure that there is content in "is"?
Bill
 
Surendran Velath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Bill.

I am printing the InputStream on the console and is as shown under XML recieved. So it is clear that the 'is' is not empty.
Someone told me that there may be extra characters at the beginning and end of the stream. But I checked and it is not so.

Surendran
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)

I notice that the parser is trying to determine the version of the XML document. Since the version is in the first line of the document, it's likely that the input stream is actually empty. That would be where I would look, despite the tests you say you did. Could you post the part of your code that surrounds this error?
 
Surendran Velath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code:

Thanks
Surendran
 
Surendran Velath
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I looked at the InputStream again. Printed it before and after unmarshalling and found that it was empty the second time.
So commented out the first printing and got proper results.
Got to be careful when reading from streams. When I printed the value from the stream, it got flushed out. So the unmarshaller got an empty stream to work with.

Thanks Paul, Thanks Bill

Surendran
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic