473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

XML- Java "Content is not allowed in prolog"

Hi Alll,
When i try to parse the string.xml which is in UTF-16LE, its working fine with JDK 1.4 but gives the following error in JDK 1.5.
Error : "Content is not allowed in prolog".
Can any one of you suggest me a solution for this.
Its very urgent.
Jan 9 '07 #1
4 8760
r035198x
13,262 8TB
Hi Alll,
When i try to parse the string.xml which is in UTF-16LE, its working fine with JDK 1.4 but gives the following error in JDK 1.5.
Error : "Content is not allowed in prolog".
Can any one of you suggest me a solution for this.
Its very urgent.
Post the code you are using if possible.
Jan 9 '07 #2
Post the code you are using if possible.

The following is the code when i convert my existing strings.xml in UTF-8 fromat to UTF-16LE.
Now when i try to parse this resultant UTF_16LE_strings.xml using JDK1.5 it is giving an error "Content is not allowed in prolog".But the same is working fine with JDK 1.4.

Below is the code of my string.xml in UTF-16LE which i try to parse.
Windows is my platform.
Please suggest me a solution.


<?xml version='1.0' encoding='UTF-8'?>
<STRING-TABLE PATH="." VERSION="1">
<LANG TYPE="EN">
<STRING ID="2" LABEL="BUTTON_TEXT1" VALUE="prev day" />
<STRING ID="3" LABEL="BUTTON_TEXT2" VALUE="next day" />
<STRING ID="4" LABEL="BUTTON_TEXT3" VALUE="reminder" />
<STRING ID="5" LABEL="HOME_LIVETV" VALUE="LIVE TV" />
<STRING ID="6" LABEL="HOME_ONDEMAND" VALUE="ON DEMAND" />
<STRING ID="7" LABEL="HOME_ONMYDEMAND" VALUE="MY ON DEMAND" />
<STRING ID="8" LABEL="HOME_SEARCHONDEMAND" VALUE="SEARCH ON DEMAND" />
<STRING ID="11" LABEL="CHNL_TYPE" VALUE="Channel Type" />
<STRING ID="13" LABEL="REGION_ID" VALUE="Region ID" />
<STRING ID="14" LABEL="ENTERTAINMENT" VALUE="Entertainment" />
<STRING ID="15" LABEL="CTYPE_MOVIES" VALUE="Movies" />
<STRING ID="16" LABEL="CTYPE_SPORT" VALUE="Sport" />
<STRING ID="17" LABEL="CTYPE_NEWS" VALUE="News" />
<STRING ID="18" LABEL="CTYPE_MUSIC" VALUE="Music" />
<STRING ID="21" LABEL="CATALOG_MUSIC" VALUE="MUSIC" />
<STRING ID="24" LABEL="PB_CHNL_TITL" VALUE="Channel Title" />
<STRING ID="25" LABEL="HO_PROMO_TXT1" VALUE="CHRONICLES OF NARNIA" />
<STRING ID="26" LABEL="HO_PROMO_TXT2" VALUE="HOWLS MOVING CASTLE" />
<STRING ID="27" LABEL="HO_ETIT_TXT" VALUE="Video Modes" />
<STRING ID="29" LABEL="HO_MHEAD" VALUE="HOME" />
<STRING ID="32" LABEL="MOD_Music" VALUE="MUSIC" />
<STRING ID="35" LABEL="MOVI_PREMIERS" VALUE="PREMIERS" />
<STRING ID="36" LABEL="CATEGORIES" VALUE="CATEGORIES" />
<STRING ID="37" LABEL="MOVI_LCHAN" VALUE="LAST CHANCE" />
<STRING ID="38" LABEL="AZ_TITLES" VALUE="A-Z TITLES" />
<STRING ID="40" LABEL="ACTION" VALUE="ACTION" />
<STRING ID="41" LABEL="MOVCAT_THR" VALUE="THRILLER" />
<STRING ID="44" LABEL="MOVCAT_FAM" VALUE="FAMILY" />
<STRING ID="46" LABEL="TVS_CUP" VALUE="CATCH UP" />
<STRING ID="53" LABEL="GUSET_CC" VALUE="CLOSED CAPTIONS" />
<STRING ID="54" LABEL="HOME_SYSSETUP" VALUE="System Setup" />
<STRING ID="55" LABEL="SYSSET_TV" VALUE="TV Setup" />
<STRING ID="57" LABEL="GUSET_PS" VALUE="PERSONAL SETTINGS" />
<STRING ID="58" LABEL="PAGE_UP_DN" VALUE="+/- Page up/down" />
<STRING ID="59" LABEL="SUNDAY" VALUE="Sunday" />
<STRING ID="60" LABEL="MONDAY" VALUE="Monday" />
<STRING ID="61" LABEL="TUESDAY" VALUE="Tuesday" />
<STRING ID="62" LABEL="WEDNESDAY" VALUE="Wednesday" />
<STRING ID="63" LABEL="THURSDAY" VALUE="Thursday" />
<STRING ID="64" LABEL="FRIDAY" VALUE="Friday" />
<STRING ID="65" LABEL="SATURDAY" VALUE="Saturday" />
<STRING ID="66" LABEL="TODAY" VALUE="Today" />
<STRING ID="67" LABEL="HO_PRORD_LBL" VALUE="ORDER NOW" />
<STRING ID="68" LABEL="EVENT_TIME" VALUE="Time" />
<STRING ID="69" LABEL="TITLE" VALUE="Title" />
<STRING ID="70" LABEL="PRSNL_SETT" VALUE="Personal Settings" />
<STRING ID="72" LABEL="RADIO_CHANNELS" VALUE="Radio Channels" />
<STRING ID="75" LABEL="EPG_LANG" VALUE="EPG Language:" />
<STRING ID="76" LABEL="RMND_AUTO_TUNE" VALUE="Reminder Auto Tune:" />
<STRING ID="77" LABEL="RMNDR_NOT" VALUE="Reminder Notification:" />
<STRING ID="78" LABEL="BANN_DURATION" VALUE="Banner Duration:" />
<STRING ID="79" LABEL="FAVOURITES" VALUE="Favourites:" />
<STRING ID="80" LABEL="SFTWARE_DWNLOAD" VALUE="Software Download:" />
<STRING ID="81" LABEL="ON_DEMACCOUNT" VALUE="On Demand Account:" />
<STRING ID="82" LABEL="Subtitle" VALUE="Subtitles:" />
<STRING ID="83" LABEL="FAV_DELETE" VALUE="Delete" />
<STRING ID="84" LABEL="GUIDE_SETT" VALUE="GUIDE SETTINGS" />
<STRING ID="85" LABEL="SUBMIT" VALUE="SUBMIT" />
<STRING ID="86" LABEL="HOME_PROGTYPE" VALUE="Program Type" />
<STRING ID="87" LABEL="BLK_SUBHEADING" VALUE="Block Channels" />
<STRING ID="88" LABEL="BLK_MESSAGE" VALUE="Please select channels to block" />
<STRING ID="89" LABEL="BLK_BUTTON1" VALUE="Parental Control Menu" />
<STRING ID="91" LABEL="RESET_DEFAULT" VALUE="Reset to Default" />
<STRING ID="92" LABEL="BLK_APPLY" VALUE="APPLY CHANGES" />
<STRING ID="93" LABEL="PCONT_RAT" VALUE="RATINGS" />
<STRING ID="94" LABEL="PCONT_VOD" VALUE="VOD RATINGS" />
<STRING ID="95" LABEL="PCONT_CBLK" VALUE="CHANNEL BLOCKING" />
<STRING ID="96" LABEL="PCONT_SPD" VALUE="SPENDING" />
<STRING ID="97" LABEL="PCONT_HRS" VALUE="HOURS" />
<STRING ID="98" LABEL="PCONT_CPIN" VALUE="CHANGE PIN" />
<STRING ID="101" LABEL="RAT_OTH" VALUE="OTHERS" />
<STRING ID="102" LABEL="ALL_CHANNELS" VALUE="ALL CHANNELS" />
<STRING ID="103" LABEL="CBLK_VOD" VALUE="VOD CHANNELS" />
<STRING ID="104" LABEL="CBLK_ADC" VALUE="ADULT CONTENT" />
<STRING ID="105" LABEL="CBLK_CHLD" VALUE="CHILDRENS" />
<STRING ID="106" LABEL="CBLK_FILM" VALUE="FILM" />
<STRING ID="107" LABEL="POPUP_HEAD" VALUE="BLOCK BELOW CHANNELS" />
</LANG>
</STRING-TABLE>
Jan 10 '07 #3
r035198x
13,262 8TB
The following is the code when i convert my existing strings.xml in UTF-8 fromat to UTF-16LE.
Now when i try to parse this resultant UTF_16LE_strings.xml using JDK1.5 it is giving an error "Content is not allowed in prolog".But the same is working fine with JDK 1.4.

Below is the code of my string.xml in UTF-16LE which i try to parse.
Windows is my platform.
Please suggest me a solution.


<?xml version='1.0' encoding='UTF-8'?>
<STRING-TABLE PATH="." VERSION="1">
<LANG TYPE="EN">
<STRING ID="2" LABEL="BUTTON_TEXT1" VALUE="prev day" />
<STRING ID="3" LABEL="BUTTON_TEXT2" VALUE="next day" />
<STRING ID="4" LABEL="BUTTON_TEXT3" VALUE="reminder" />
<STRING ID="5" LABEL="HOME_LIVETV" VALUE="LIVE TV" />
<STRING ID="6" LABEL="HOME_ONDEMAND" VALUE="ON DEMAND" />
<STRING ID="7" LABEL="HOME_ONMYDEMAND" VALUE="MY ON DEMAND" />
<STRING ID="8" LABEL="HOME_SEARCHONDEMAND" VALUE="SEARCH ON DEMAND" />
<STRING ID="11" LABEL="CHNL_TYPE" VALUE="Channel Type" />
<STRING ID="13" LABEL="REGION_ID" VALUE="Region ID" />
<STRING ID="14" LABEL="ENTERTAINMENT" VALUE="Entertainment" />
<STRING ID="15" LABEL="CTYPE_MOVIES" VALUE="Movies" />
<STRING ID="16" LABEL="CTYPE_SPORT" VALUE="Sport" />
<STRING ID="17" LABEL="CTYPE_NEWS" VALUE="News" />
<STRING ID="18" LABEL="CTYPE_MUSIC" VALUE="Music" />
<STRING ID="21" LABEL="CATALOG_MUSIC" VALUE="MUSIC" />
<STRING ID="24" LABEL="PB_CHNL_TITL" VALUE="Channel Title" />
<STRING ID="25" LABEL="HO_PROMO_TXT1" VALUE="CHRONICLES OF NARNIA" />
<STRING ID="26" LABEL="HO_PROMO_TXT2" VALUE="HOWLS MOVING CASTLE" />
<STRING ID="27" LABEL="HO_ETIT_TXT" VALUE="Video Modes" />
<STRING ID="29" LABEL="HO_MHEAD" VALUE="HOME" />
<STRING ID="32" LABEL="MOD_Music" VALUE="MUSIC" />
<STRING ID="35" LABEL="MOVI_PREMIERS" VALUE="PREMIERS" />
<STRING ID="36" LABEL="CATEGORIES" VALUE="CATEGORIES" />
<STRING ID="37" LABEL="MOVI_LCHAN" VALUE="LAST CHANCE" />
<STRING ID="38" LABEL="AZ_TITLES" VALUE="A-Z TITLES" />
<STRING ID="40" LABEL="ACTION" VALUE="ACTION" />
<STRING ID="41" LABEL="MOVCAT_THR" VALUE="THRILLER" />
<STRING ID="44" LABEL="MOVCAT_FAM" VALUE="FAMILY" />
<STRING ID="46" LABEL="TVS_CUP" VALUE="CATCH UP" />
<STRING ID="53" LABEL="GUSET_CC" VALUE="CLOSED CAPTIONS" />
<STRING ID="54" LABEL="HOME_SYSSETUP" VALUE="System Setup" />
<STRING ID="55" LABEL="SYSSET_TV" VALUE="TV Setup" />
<STRING ID="57" LABEL="GUSET_PS" VALUE="PERSONAL SETTINGS" />
<STRING ID="58" LABEL="PAGE_UP_DN" VALUE="+/- Page up/down" />
<STRING ID="59" LABEL="SUNDAY" VALUE="Sunday" />
<STRING ID="60" LABEL="MONDAY" VALUE="Monday" />
<STRING ID="61" LABEL="TUESDAY" VALUE="Tuesday" />
<STRING ID="62" LABEL="WEDNESDAY" VALUE="Wednesday" />
<STRING ID="63" LABEL="THURSDAY" VALUE="Thursday" />
<STRING ID="64" LABEL="FRIDAY" VALUE="Friday" />
<STRING ID="65" LABEL="SATURDAY" VALUE="Saturday" />
<STRING ID="66" LABEL="TODAY" VALUE="Today" />
<STRING ID="67" LABEL="HO_PRORD_LBL" VALUE="ORDER NOW" />
<STRING ID="68" LABEL="EVENT_TIME" VALUE="Time" />
<STRING ID="69" LABEL="TITLE" VALUE="Title" />
<STRING ID="70" LABEL="PRSNL_SETT" VALUE="Personal Settings" />
<STRING ID="72" LABEL="RADIO_CHANNELS" VALUE="Radio Channels" />
<STRING ID="75" LABEL="EPG_LANG" VALUE="EPG Language:" />
<STRING ID="76" LABEL="RMND_AUTO_TUNE" VALUE="Reminder Auto Tune:" />
<STRING ID="77" LABEL="RMNDR_NOT" VALUE="Reminder Notification:" />
<STRING ID="78" LABEL="BANN_DURATION" VALUE="Banner Duration:" />
<STRING ID="79" LABEL="FAVOURITES" VALUE="Favourites:" />
<STRING ID="80" LABEL="SFTWARE_DWNLOAD" VALUE="Software Download:" />
<STRING ID="81" LABEL="ON_DEMACCOUNT" VALUE="On Demand Account:" />
<STRING ID="82" LABEL="Subtitle" VALUE="Subtitles:" />
<STRING ID="83" LABEL="FAV_DELETE" VALUE="Delete" />
<STRING ID="84" LABEL="GUIDE_SETT" VALUE="GUIDE SETTINGS" />
<STRING ID="85" LABEL="SUBMIT" VALUE="SUBMIT" />
<STRING ID="86" LABEL="HOME_PROGTYPE" VALUE="Program Type" />
<STRING ID="87" LABEL="BLK_SUBHEADING" VALUE="Block Channels" />
<STRING ID="88" LABEL="BLK_MESSAGE" VALUE="Please select channels to block" />
<STRING ID="89" LABEL="BLK_BUTTON1" VALUE="Parental Control Menu" />
<STRING ID="91" LABEL="RESET_DEFAULT" VALUE="Reset to Default" />
<STRING ID="92" LABEL="BLK_APPLY" VALUE="APPLY CHANGES" />
<STRING ID="93" LABEL="PCONT_RAT" VALUE="RATINGS" />
<STRING ID="94" LABEL="PCONT_VOD" VALUE="VOD RATINGS" />
<STRING ID="95" LABEL="PCONT_CBLK" VALUE="CHANNEL BLOCKING" />
<STRING ID="96" LABEL="PCONT_SPD" VALUE="SPENDING" />
<STRING ID="97" LABEL="PCONT_HRS" VALUE="HOURS" />
<STRING ID="98" LABEL="PCONT_CPIN" VALUE="CHANGE PIN" />
<STRING ID="101" LABEL="RAT_OTH" VALUE="OTHERS" />
<STRING ID="102" LABEL="ALL_CHANNELS" VALUE="ALL CHANNELS" />
<STRING ID="103" LABEL="CBLK_VOD" VALUE="VOD CHANNELS" />
<STRING ID="104" LABEL="CBLK_ADC" VALUE="ADULT CONTENT" />
<STRING ID="105" LABEL="CBLK_CHLD" VALUE="CHILDRENS" />
<STRING ID="106" LABEL="CBLK_FILM" VALUE="FILM" />
<STRING ID="107" LABEL="POPUP_HEAD" VALUE="BLOCK BELOW CHANNELS" />
</LANG>
</STRING-TABLE>
I meant post the Java code you are using to parse the XML file.
Jan 10 '07 #4
I meant post the Java code you are using to parse the XML file.
DocumentBulider docBuilder = DocumentBuilderFactory.newInstance().newDocumentBu ilder();

stringXML = FileConverter.UTF8ToUTF16(stringXML);
document = docBuilder.parse(stringXML);
parseXML();





public static File UTF8ToUTF16(File file) {
final String FILE_PREFIX = "UTF_16LE_";
File inputFile = null;
InputStream fis = null;
InputStreamReader isr = null;
File outputFile = null;
OutputStream fos = null;
OutputStream bos = null;
OutputStreamWriter osw = null;

try {
inputFile = file;
fis = new FileInputStream(inputFile);
isr = new InputStreamReader(fis, "UTF-8");
outputFile = new File(inputFile.getParentFile(), FILE_PREFIX + inputFile.getName());
fos = new FileOutputStream(outputFile);
bos = new BufferedOutputStream(fos);
osw = new OutputStreamWriter(bos, "UTF-16LE");

} catch (FileNotFoundException fne) {
LogScreen.setErrorMsg("File not found !");
} catch (UnsupportedEncodingException ue) {
LogScreen.setErrorMsg("Encoding not supported !");
}

int c;
try {
while ((c = isr.read()) != -1) {
osw.write(c);
}
osw.flush();
osw.close();
isr.close();
} catch (IOException ie) {
LogScreen.setErrorMsg("Unable read the file !");
}

LogScreen.setErrorMsg(LogScreen.INFO+"File conversion to UTF-16 successfully completed.");

return outputFile;

}
Jan 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Harry Young | last post by:
Webmasters: Colance specialise in connecting your ideas with Freelance Professionals to produce your project. Programmers: Providing your Service is made easy through Colance. It is free to sign up...
0
by: Tina Coleman | last post by:
http://www.colance.com Webmasters: Colance specialise in connecting your ideas with Freelance Professionals to produce your project. Programmers: Providing your Service is made easy through...
0
by: Ryan Scott | last post by:
Webmasters: Colance specialise in connecting your ideas with Freelance Professionals to produce your project. Programmers: Providing your Service is made easy through Colance. It is free to sign up...
1
by: Paul Hernandez | last post by:
Webmasters: Colance specialise in connecting your ideas with Freelance Professionals to produce your project. Programmers: Providing your Service is made easy through Colance. It is free to sign up...
2
by: Robert M. Gary | last post by:
I'm using JRE 1.5 on Solaris Japanese (Sparc). The JVM claims its default character set is EUC-JP I'm seeing two strange things when using Japanese character sets... 1) If I write a program that...
0
by: Olivier Ishacian | last post by:
XMLmind XML Editor V3.0 Patch 1 can be downloaded from http://www.xmlmind.com/xmleditor/download.shtml _____________________________________________ V3.0 Patch 1 (December 2, 2005) ...
7
by: mjarends | last post by:
I'm using JAXP for XSLT - I'm using the examples from http://www.w3.org/TR/xslt#section-Examples. I'm using the following XML file: <?xml version="1.0" encoding="UTF-8"?> <sales> <division...
1
by: surajhs | last post by:
i need to convert image to binary data and create xml file in applet, Please send samples links
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.