my dog learned polymorphism
The moose likes XML and Related Technologies and the fly likes dtd parsing  error 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 "dtd parsing  error" Watch "dtd parsing  error" New topic

dtd parsing error

Josweth Reddy
Ranch Hand

Joined: Nov 02, 2005
Posts: 30
Hi Everyone,
Im new to JAXB and Im deploying a sample application to unmarshal from the xml document. While using the xjc command to generate the jaav code,facing an error saying that

"parsing a schema...[ERROR] The markup in the document preceding the root element must be well-formed."

The below is the dtd file
<!ELEMENT item_list (item_info*)>
<!ELEMENT item_info (#PCDATA)>
<!ELEMENT price (#PCDATA)>

xjc command using
xjc item.dtd item.xjs

Please help me out to generate the java code by executing the xjc command.

Thanks in advance,
Josweth Reddy
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Just glancing at the XJC documentation here it appears that xjc assumes all input files are schema so it is trying to parse your dtd as xml and fails giving you an XML parsing error.

Josweth Reddy
Ranch Hand

Joined: Nov 02, 2005
Posts: 30
Hi Bill,

Thanks for the clarification. But I would like to develop a sample application using JAXB. Shall I go for the xsd file instead of dtd ?. Or else please tell me the alternate.

Josweth Reddy

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Here is a link to an article about the architecture of JAXB. Notice how it continually mentions schemas? Anyway, if you scan it for "DTD" you will find it has some advice for what to do about DTDs.
I agree. Here's the link:
subject: dtd parsing error
It's not a secret anymore!