File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Validating an XML File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Validating an XML File " Watch "Validating an XML File " New topic
Author

Validating an XML File

pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Hello Ranchers,

I was trying to validate an xml file with an schema. I have attached the class that does it and the xml file and the schema file. I am able to validate this xml file with the schema using stylus studio. But when i run this class i get and error saying
Cannot find the declaration of element 'note'.




I hae spent lots of time on this and am not able to figure out what i am doing wrong.

Thanks for your help.....



Pradeep



The XMl File is.....





And the schema is.....



[<a href="http://cyvis.sourceforge.net" target="_blank" rel="nofollow">CyVis - Software Complexity Visualiser</a>] [<a href="http://pradeepselvaraj.blogspot.com" target="_blank" rel="nofollow">Pradeep's Blog</a>]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18655
    
    8

Constructing your own file URIs by a simple concatenation is not reliable. That's why the java.io.File class has a toURI() method. Why not use that?
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
I have tried using the toURI method, but get the same message...

This is what i had changed in my coded.


Is there some other place where i could have gone wrong?

Thanks a Lot
Pradeep
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18655
    
    8

Could be. What does this expression produce?Is that what you are supposed to use there?
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Thanks very much....

The code does validate the xml that have only one schema file.

What should i add in order to validate an xml file whose schema is specified in multiple files? That is one main schema which imports multiple schema file?
The above coded works well if there is one schema file, and does not when the main scheman imports other schema files.

Please advice...


Thanks again

Pradeep
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validating an XML File