This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Is anybody have solution for this... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Is anybody have solution for this..." Watch "Is anybody have solution for this..." New topic

Is anybody have solution for this...

arun sharma

Joined: Jul 02, 2003
Posts: 19
I am using DOM- Apache Xerces 2.4.0 and Schema to validate a simple document , BUt I am getting this error:
Error: URI=file:///D:/Test/XML/Test.xml Line=2: Document is invalid: no grammar found.
Error: URI=file:///D:/Test/XML/Test.xml Line=2: Document root element "NAME", must match DOCTYPE root "null".
This is the code i am usinf
XML File
<?xml version="1.0" encoding="UTF-8"?>
Schema File:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="">
<xs:element name="NAME">
<xs:element name="FIRST_NAME" type="xs:string"/>
<xs:element name="LAST_NAME" type="xs:string"/>
Java File
import javax.xml.parsers.*;
public class ActaSU {
public ActaSU() {
public static void main(String[] args) {
//ProductEventHandler producteventhandler = new ProductEventHandler();
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
dbf.setAttribute("", "");
dbf.setAttribute("", new File("test.xsd"));
} catch (Exception exception) {
arun sharma

Joined: Jul 02, 2003
Posts: 19
Roshan Lal
Ranch Hand

Joined: Nov 13, 2001
Posts: 64
Hi Arun,
Today I faced the same problem and came to this site for some pointers.
Just now my problem got solved. I had to put the xerces.jar ahead of all
other jars. Looks like there were other parsers in the classpath.
Try this and see if that helps.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Is anybody have solution for this...
It's not a secret anymore!