File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to validate XML against the schema

 
Sharon whipple
Ranch Hand
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 294
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SchemaLocation attributes are for reference purposes only and should not be relied upon "programatically" or for any execution task such as instance validation.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic