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 Once again - XML Schema validation problems cvc-elt.1 Cannot find the declaration of element 'order' 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 "Once again - XML Schema validation problems cvc-elt.1 Cannot find the declaration of element Watch "Once again - XML Schema validation problems cvc-elt.1 Cannot find the declaration of element New topic
Forums: JDBC XML and Related Technologies
Author

Once again - XML Schema validation problems cvc-elt.1 Cannot find the declaration of element 'order'

Peter Thunderstone
Greenhorn

Joined: Apr 21, 2013
Posts: 3
Hi all,

please consider this Big Moose FAQ page, how to validate XML:
http://www.coderanch.com/how-to/java/HowToValidateXmlAgainstAnySchema

Along this, the following code and a simple data sample deliver an error however.

Troubleshooting:
- XML+XSD checked online here, they seem to be okay then http://www.freeformatter.com/xml-validator-xsd.html
- Local web server is working; if XSD url is changed, program reports connection error
- Local XML file is also there, changing its name causes a file not found error

Questions/Discussion:
- Q1 How to validate against schema, defining its location via code e.g. externally to the XML, so without changing the XML data (e.g. online tool might not load test.xsd locally to do the check)?
- Q2 How to validate passing schema as an xml schema string?
- Q3 Is it possible to validate an XML string without reading from disk?

Relevant error output (omitting warning about required custom error handler):



Java Code:


XML



XSD



Any help appreciated - cheers!
Noob

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Don't know I am afraid. I shall move this to our XML forum because it is too difficult for “beginning”.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 547
    
    3
The single major reason for the validation resulting in a failure is that the document builder is not namespace-aware by default. You have to set its awareness.

Once you get this case behind, you can sure google more to get a handle on your Questions/Discussion with more confidence.
Peter Thunderstone
Greenhorn

Joined: Apr 21, 2013
Posts: 3
Hi, thank you for your reply... but... this method can be used solely for asking for this type of configuration? No parameter pass, not setter method in this class for that?..


g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 547
    
    3
That is my bad, sorry! I should post the setting on the factory.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Once again - XML Schema validation problems cvc-elt.1 Cannot find the declaration of element 'order'