jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes Why it is happening like this......... 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 "Why it is happening like this........." Watch "Why it is happening like this........." New topic

Why it is happening like this.........

arun sharma

Joined: Jul 02, 2003
Posts: 19
I am getting following errors:
Error: Document is invalid: no grammar found.
Error: Document root element "NAME", must match DOCTYPE root "null".
I am having is simple XML Schema , XML file and Using Xerces 2.4 parser
I am attaching the XML , Schema and java file
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="NAME">
<xs:element name="FIRST_NAME" type="xs:string" />
<xs:element name="LAST_NAME" type="xs:string" />
import java.io.File;

import javax.xml.parsers.*;
import javax.xml.parsers.*;
//import org.apache.xerces.parsers.SAXParser;

public class WellFormednessChecker {
public static void main(String[] args) {
ProductEventHandler handler = new ProductEventHandler();
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
} catch (Exception e) {
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
you have turn on schema validation for this using setFeature
try the below code(got from ibm tutorial)https://www6.software.ibm.com/developerworks/education/x-xschema/x-xschema-4-1.html

Spritle Software Blogs
arun sharma

Joined: Jul 02, 2003
Posts: 19
Hi Balaji;
I tried the same as u told but still same problem..
The proble here is the XML file is not able to locate the Schema file ...
I don't know what's happening...
Can u see whether the schema inclusion in xml is correct or not..
arun sharma

Joined: Jul 02, 2003
Posts: 19
Hi Balaji;
I got the solution actually we have to set the Feature like this:
then it works fine
anyway thanks for support...
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Why it is happening like this.........
It's not a secret anymore!