Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 26th, 2003, 01:37 AM
srivalli9 srivalli9 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 48 srivalli9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 4 sec
Reputation Power: 6
ERROR while XML is accessed using JAXP API and DOM parser

Hi,

when i tried to parse the xml document using DOM parser from JAXP API,
I got an error...

org.xml.sax.SAXParseException: XML declaration may only begin entities.
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3170)
at org.apache.crimson.parser.Parser2.maybePI(Parser2.java:966)
at org.apache.crimson.parser.Parser2.maybeMisc(Parser2.java:1092)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:487)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)

at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl
.java:185)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:151)
at XMLBean.getCustInfo(XMLBean.java:34)
at XMLBean.main(XMLBean.java:122)


When I printed the line number out, it showed the line where my processing instruction of XML is coded(i.e.,<?xml version="1.0" ?>).
here it goes....

custinfo.xml
------------
<!-- Name: Srivalli Chavali
DateSubmited: 4/15/03
Purpose: XML file to store Customer information of VegDeliPlus-->

<!--sdfdf-->
<?xml version="1.0" ?>

<!-- DTD to define the language for VegDeliPlus customers -->
<!DOCTYPE custlist [
<!ELEMENT custlist (cust+)>
<!ELEMENT cust (name, amtowed, addr, numpeople)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT amtowed (#PCDATA)>
<!ELEMENT addr (#PCDATA)>
<!ELEMENT numpeople (#PCDATA)>
<!ATTLIST cust credrating (1|2|3) #REQUIRED>
<!ATTLIST numpeople good (Yes|No) "No">
]>

<!-- VegDeliPlus Database as an XML file -->
<custlist>
<cust credrating="1">
<name>James Gosling</name>
<amtowed>$0.00</amtowed>
<addr>12 Java Lane</addr>
<numpeople>6</numpeople>
</cust>
<cust credrating="3">
<name>Ronda Smith</name>
<amtowed>$85.50</amtowed>
<addr>345 Rocky Rd.</addr>
<numpeople good="Yes">25</numpeople>
</cust>
<cust credrating="2">
<name>Larry Lake</name>
<amtowed>$255.85</amtowed>
<addr>249 Lakeview Blvd.</addr>
<numpeople good="Yes">112</numpeople>
</cust>
<cust credrating="1">
<name>Sally Snow</name>
<amtowed>$1,000.00</amtowed>
<addr>11 Snowbird Blvd.</addr>
<numpeople>19</numpeople>
</cust>
<cust credrating="2">
<name>Ron Padova</name>
<amtowed>$1,000.00</amtowed>
<addr>282 East 12th St.</addr>
<numpeople good="Yes">20</numpeople>
</cust>
<cust credrating="3">
<name>Sue Jones</name>
<amtowed></amtowed>
<addr>45 Ruler Rd.</addr>
<numpeople>4</numpeople>
</cust>
<cust credrating="1">
<name>Robert Trent</name>
<amtowed>$240.00</amtowed>
<addr>23 Golfway Ave.</addr>
<numpeople good="Yes">24</numpeople>
</cust>
<cust credrating="2">
<name>LiChing Wu</name>
<amtowed>$45.55</amtowed>
<addr>873 Richmond Rd.</addr>
<numpeople>13</numpeople>
</cust>
<cust credrating="2">
<name>Narasimhiah Patel</name>
<amtowed>$45.55</amtowed>
<addr>26 Oakview Rd.</addr>
<numpeople good="Yes">28</numpeople>
</cust>
<cust credrating="1">
<name>Rachel Carter</name>
<amtowed>$25.00</amtowed>
<addr>1122 Erieview Ave.</addr>
<numpeople>18</numpeople>
</cust>
<cust credrating="3">
<name>Tom Tally</name>
<amtowed>$0.00</amtowed>
<addr>25 TallyHo Rd.</addr>
<numpeople good="Yes">77</numpeople>
</cust>
</custlist>
----------------------------------------------------------------
I cannot understand whats wrong in it.
If I run my program removing the statement <?xml version="1.0" ?> from this custinfo.xml file, it WORKS FINE.
Can anyone please tell me what the problem in that statement is?

Reply With Quote
  #2  
Old April 26th, 2003, 11:50 AM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
I think the line
Code:
<?xml version="1.0" ?>

HAS to be the first line. You have comments before it.

Reply With Quote
  #3  
Old April 26th, 2003, 02:43 PM
srivalli9 srivalli9 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 48 srivalli9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 4 sec
Reputation Power: 6
Oh! Great!
Thanks a lot, Nemi...its working!!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > ERROR while XML is accessed using JAXP API and DOM parser


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway