permaculture playing cards*
The moose likes XML and Related Technologies and the fly likes UTF-16 Encoding -Content is not allowed in prolog. 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 "UTF-16 Encoding -Content is not allowed in prolog." Watch "UTF-16 Encoding -Content is not allowed in prolog." New topic
Author

UTF-16 Encoding -Content is not allowed in prolog.

Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73

I have a schema declaration with following prolog

<?xml version="1.0" encoding="UTF-16" standalone="yes"?>

Also i have generated a XML file based on this which has following prolog

<?xml version = '1.0' encoding="UTF-16"?>

My program that reads the XML file gives following error on execution .The data read occurs only if validation of XML with schema succeeds

But i always gets an error

"Error While Validating
Content is not allowed in prolog."

where am i going wrong?


But when i made following changes

<?xml version="1.0" encoding="windows-1252" standalone="yes"?>


<?xml version = '1.0' ?>(i.e skipped encoding )

I was not getting errors






Please tell where have i made mistake.I s this way to use UTF-16 encoding?













A table, a chair, a bowl of fruit and a violin; what else does a man need to be happy?:Einstein
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Content is not allowed in prolog.


Sometimes that error can be caused by something as simple as a leading blank line or a single leading spce in the file text.

Always doublecheck that the < is the very first character in the file.

Bill

Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73
Thanks a lot for the reply.
No its not the problem . I found so many people saying about getting of this error due to a reason as you said.But in my case its not else it would have thrown the same error for the other one also rite...
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, you should actually use UTF-16 for the encoding. Saying it's encoded in UTF-16 when it's actually encoded in some other charset is likely to cause problems. Perhaps even that one, I don't know.
Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73
Thank you for the reply . I will try once again changing it to UTF-16
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UTF-16 Encoding -Content is not allowed in prolog.