• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Peter Thunderstone
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49472
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 667
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 667
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is my bad, sorry! I should post the setting on the factory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic