By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,737 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,737 IT Pros & Developers. It's quick & easy.

XML- Java "Content is not allowed in prolog"

P: 6
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
Share this Question
Share on Google+
4 Replies


10K+
P: 13,264
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

P: 6
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

10K+
P: 13,264
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

P: 6
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

Post your reply

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