Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes Unable to validate XML against the schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Unable to validate XML against the schema" Watch "Unable to validate XML against the schema" New topic
Author

Unable to validate XML against the schema

Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Hi all
I am able to validate XML against its schema when I am reading the XSD from external file like this:


But I am unable to validate the XML when the schema is part of the main element of my xml like so:


I keep getting error :
Document root element must match DOCTYPE root "null".

Any idea why?

Thank you!!

Sharon
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So, I'm guessing that declaring the schema location in that fashion says that the schema is supposed to be in the same directory as the XML document? And is it? And are you passing the XML document to the parser in such a way that it can determine a system ID to locate the document and the schema by?
Sharon whipple
Ranch Hand

Joined: Jul 31, 2003
Posts: 294
Paul Clapham wrote:So, I'm guessing that declaring the schema location in that fashion says that the schema is supposed to be in the same directory as the XML document?
And is it? And are you passing the XML document to the parser in such a way that it can determine a system ID to locate the document and the schema by?


The XSD and XML are in the same dir,

I am passing a "File" obj to the XML to the parser

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Then probably I'm wrong about what it means to provide a relative URL for the schema location. I'm no schema expert, so I don't know what it means either. You should look that up.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
SchemaLocation attributes are for reference purposes only and should not be relied upon "programatically" or for any execution task such as instance validation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to validate XML against the schema
 
Similar Threads
specify root for xsd validation
xml validation with the java 5
Loading a schema that refers to another one.
valiating xml using multiple schemas
XSD validation in XML