473,769 Members | 5,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML- Java "Content is not allowed in prolog"

6 New Member
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 8786
r035198x
13,262 MVP
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
dmvsatyakumar
6 New Member
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_string s.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_T EXT1" VALUE="prev day" />
<STRING ID="3" LABEL="BUTTON_T EXT2" VALUE="next day" />
<STRING ID="4" LABEL="BUTTON_T EXT3" VALUE="reminder " />
<STRING ID="5" LABEL="HOME_LIV ETV" VALUE="LIVE TV" />
<STRING ID="6" LABEL="HOME_OND EMAND" VALUE="ON DEMAND" />
<STRING ID="7" LABEL="HOME_ONM YDEMAND" VALUE="MY ON DEMAND" />
<STRING ID="8" LABEL="HOME_SEA RCHONDEMAND" VALUE="SEARCH ON DEMAND" />
<STRING ID="11" LABEL="CHNL_TYP E" VALUE="Channel Type" />
<STRING ID="13" LABEL="REGION_I D" VALUE="Region ID" />
<STRING ID="14" LABEL="ENTERTAI NMENT" VALUE="Entertai nment" />
<STRING ID="15" LABEL="CTYPE_MO VIES" VALUE="Movies" />
<STRING ID="16" LABEL="CTYPE_SP ORT" VALUE="Sport" />
<STRING ID="17" LABEL="CTYPE_NE WS" VALUE="News" />
<STRING ID="18" LABEL="CTYPE_MU SIC" 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="CHRONICL ES 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_Musi c" VALUE="MUSIC" />
<STRING ID="35" LABEL="MOVI_PRE MIERS" VALUE="PREMIERS " />
<STRING ID="36" LABEL="CATEGORI ES" VALUE="CATEGORI ES" />
<STRING ID="37" LABEL="MOVI_LCH AN" VALUE="LAST CHANCE" />
<STRING ID="38" LABEL="AZ_TITLE S" VALUE="A-Z TITLES" />
<STRING ID="40" LABEL="ACTION" VALUE="ACTION" />
<STRING ID="41" LABEL="MOVCAT_T HR" VALUE="THRILLER " />
<STRING ID="44" LABEL="MOVCAT_F AM" 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_SYS SETUP" VALUE="System Setup" />
<STRING ID="55" LABEL="SYSSET_T V" 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="WEDNESDA Y" VALUE="Wednesda y" />
<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_TI ME" VALUE="Time" />
<STRING ID="69" LABEL="TITLE" VALUE="Title" />
<STRING ID="70" LABEL="PRSNL_SE TT" VALUE="Personal Settings" />
<STRING ID="72" LABEL="RADIO_CH ANNELS" VALUE="Radio Channels" />
<STRING ID="75" LABEL="EPG_LANG " VALUE="EPG Language:" />
<STRING ID="76" LABEL="RMND_AUT O_TUNE" VALUE="Reminder Auto Tune:" />
<STRING ID="77" LABEL="RMNDR_NO T" VALUE="Reminder Notification:" />
<STRING ID="78" LABEL="BANN_DUR ATION" VALUE="Banner Duration:" />
<STRING ID="79" LABEL="FAVOURIT ES" VALUE="Favourit es:" />
<STRING ID="80" LABEL="SFTWARE_ DWNLOAD" VALUE="Software Download:" />
<STRING ID="81" LABEL="ON_DEMAC COUNT" VALUE="On Demand Account:" />
<STRING ID="82" LABEL="Subtitle " VALUE="Subtitle s:" />
<STRING ID="83" LABEL="FAV_DELE TE" VALUE="Delete" />
<STRING ID="84" LABEL="GUIDE_SE TT" VALUE="GUIDE SETTINGS" />
<STRING ID="85" LABEL="SUBMIT" VALUE="SUBMIT" />
<STRING ID="86" LABEL="HOME_PRO GTYPE" VALUE="Program Type" />
<STRING ID="87" LABEL="BLK_SUBH EADING" VALUE="Block Channels" />
<STRING ID="88" LABEL="BLK_MESS AGE" VALUE="Please select channels to block" />
<STRING ID="89" LABEL="BLK_BUTT ON1" VALUE="Parental Control Menu" />
<STRING ID="91" LABEL="RESET_DE FAULT" VALUE="Reset to Default" />
<STRING ID="92" LABEL="BLK_APPL Y" VALUE="APPLY CHANGES" />
<STRING ID="93" LABEL="PCONT_RA T" VALUE="RATINGS" />
<STRING ID="94" LABEL="PCONT_VO D" VALUE="VOD RATINGS" />
<STRING ID="95" LABEL="PCONT_CB LK" VALUE="CHANNEL BLOCKING" />
<STRING ID="96" LABEL="PCONT_SP D" VALUE="SPENDING " />
<STRING ID="97" LABEL="PCONT_HR S" VALUE="HOURS" />
<STRING ID="98" LABEL="PCONT_CP IN" VALUE="CHANGE PIN" />
<STRING ID="101" LABEL="RAT_OTH" VALUE="OTHERS" />
<STRING ID="102" LABEL="ALL_CHAN NELS" 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_CHL D" VALUE="CHILDREN S" />
<STRING ID="106" LABEL="CBLK_FIL M" VALUE="FILM" />
<STRING ID="107" LABEL="POPUP_HE AD" VALUE="BLOCK BELOW CHANNELS" />
</LANG>
</STRING-TABLE>
Jan 10 '07 #3
r035198x
13,262 MVP
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_string s.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_T EXT1" VALUE="prev day" />
<STRING ID="3" LABEL="BUTTON_T EXT2" VALUE="next day" />
<STRING ID="4" LABEL="BUTTON_T EXT3" VALUE="reminder " />
<STRING ID="5" LABEL="HOME_LIV ETV" VALUE="LIVE TV" />
<STRING ID="6" LABEL="HOME_OND EMAND" VALUE="ON DEMAND" />
<STRING ID="7" LABEL="HOME_ONM YDEMAND" VALUE="MY ON DEMAND" />
<STRING ID="8" LABEL="HOME_SEA RCHONDEMAND" VALUE="SEARCH ON DEMAND" />
<STRING ID="11" LABEL="CHNL_TYP E" VALUE="Channel Type" />
<STRING ID="13" LABEL="REGION_I D" VALUE="Region ID" />
<STRING ID="14" LABEL="ENTERTAI NMENT" VALUE="Entertai nment" />
<STRING ID="15" LABEL="CTYPE_MO VIES" VALUE="Movies" />
<STRING ID="16" LABEL="CTYPE_SP ORT" VALUE="Sport" />
<STRING ID="17" LABEL="CTYPE_NE WS" VALUE="News" />
<STRING ID="18" LABEL="CTYPE_MU SIC" 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="CHRONICL ES 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_Musi c" VALUE="MUSIC" />
<STRING ID="35" LABEL="MOVI_PRE MIERS" VALUE="PREMIERS " />
<STRING ID="36" LABEL="CATEGORI ES" VALUE="CATEGORI ES" />
<STRING ID="37" LABEL="MOVI_LCH AN" VALUE="LAST CHANCE" />
<STRING ID="38" LABEL="AZ_TITLE S" VALUE="A-Z TITLES" />
<STRING ID="40" LABEL="ACTION" VALUE="ACTION" />
<STRING ID="41" LABEL="MOVCAT_T HR" VALUE="THRILLER " />
<STRING ID="44" LABEL="MOVCAT_F AM" 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_SYS SETUP" VALUE="System Setup" />
<STRING ID="55" LABEL="SYSSET_T V" 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="WEDNESDA Y" VALUE="Wednesda y" />
<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_TI ME" VALUE="Time" />
<STRING ID="69" LABEL="TITLE" VALUE="Title" />
<STRING ID="70" LABEL="PRSNL_SE TT" VALUE="Personal Settings" />
<STRING ID="72" LABEL="RADIO_CH ANNELS" VALUE="Radio Channels" />
<STRING ID="75" LABEL="EPG_LANG " VALUE="EPG Language:" />
<STRING ID="76" LABEL="RMND_AUT O_TUNE" VALUE="Reminder Auto Tune:" />
<STRING ID="77" LABEL="RMNDR_NO T" VALUE="Reminder Notification:" />
<STRING ID="78" LABEL="BANN_DUR ATION" VALUE="Banner Duration:" />
<STRING ID="79" LABEL="FAVOURIT ES" VALUE="Favourit es:" />
<STRING ID="80" LABEL="SFTWARE_ DWNLOAD" VALUE="Software Download:" />
<STRING ID="81" LABEL="ON_DEMAC COUNT" VALUE="On Demand Account:" />
<STRING ID="82" LABEL="Subtitle " VALUE="Subtitle s:" />
<STRING ID="83" LABEL="FAV_DELE TE" VALUE="Delete" />
<STRING ID="84" LABEL="GUIDE_SE TT" VALUE="GUIDE SETTINGS" />
<STRING ID="85" LABEL="SUBMIT" VALUE="SUBMIT" />
<STRING ID="86" LABEL="HOME_PRO GTYPE" VALUE="Program Type" />
<STRING ID="87" LABEL="BLK_SUBH EADING" VALUE="Block Channels" />
<STRING ID="88" LABEL="BLK_MESS AGE" VALUE="Please select channels to block" />
<STRING ID="89" LABEL="BLK_BUTT ON1" VALUE="Parental Control Menu" />
<STRING ID="91" LABEL="RESET_DE FAULT" VALUE="Reset to Default" />
<STRING ID="92" LABEL="BLK_APPL Y" VALUE="APPLY CHANGES" />
<STRING ID="93" LABEL="PCONT_RA T" VALUE="RATINGS" />
<STRING ID="94" LABEL="PCONT_VO D" VALUE="VOD RATINGS" />
<STRING ID="95" LABEL="PCONT_CB LK" VALUE="CHANNEL BLOCKING" />
<STRING ID="96" LABEL="PCONT_SP D" VALUE="SPENDING " />
<STRING ID="97" LABEL="PCONT_HR S" VALUE="HOURS" />
<STRING ID="98" LABEL="PCONT_CP IN" VALUE="CHANGE PIN" />
<STRING ID="101" LABEL="RAT_OTH" VALUE="OTHERS" />
<STRING ID="102" LABEL="ALL_CHAN NELS" 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_CHL D" VALUE="CHILDREN S" />
<STRING ID="106" LABEL="CBLK_FIL M" VALUE="FILM" />
<STRING ID="107" LABEL="POPUP_HE AD" 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
dmvsatyakumar
6 New Member
I meant post the Java code you are using to parse the XML file.
DocumentBulider docBuilder = DocumentBuilder Factory.newInst ance().newDocum entBuilder();

stringXML = FileConverter.UTF8ToUTF16(stringXML);
document = docBuilder.pars e(stringXML);
parseXML();





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

try {
inputFile = file;
fis = new FileInputStream (inputFile);
isr = new InputStreamRead er(fis, "UTF-8");
outputFile = new File(inputFile. getParentFile() , FILE_PREFIX + inputFile.getNa me());
fos = new FileOutputStrea m(outputFile);
bos = new BufferedOutputS tream(fos);
osw = new OutputStreamWri ter(bos, "UTF-16LE");

} catch (FileNotFoundEx ception fne) {
LogScreen.setEr rorMsg("File not found !");
} catch (UnsupportedEnc odingException ue) {
LogScreen.setEr rorMsg("Encodin g not supported !");
}

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

LogScreen.setEr rorMsg(LogScree n.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
1447
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 with no monthly costs.
0
1841
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 Colance. It is free to sign up with no monthly costs. http://www.colance.co
0
1608
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 with no monthly costs. http://www.colance.co
1
2171
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 with no monthly costs lWbnBhc
2
3353
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 does System.out.println("$^%$%^^" ); //assume those are Japanese characters that are multibyte under EUC-JP The resulting output looks NOTHING like the characters I typed in. Apparently the character set being used to read the literal is...
0
1297
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) Enhancements: ~~~~~~~~~~~~~
7
3540
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 id="North"> <revenue>10</revenue> <growth>9</growth>
1
4013
by: surajhs | last post by:
i need to convert image to binary data and create xml file in applet, Please send samples links
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.