This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I have some problens with validating my xml file. I get the error message "cvc-elt.1: Cannot find the declaration of element 'xsi:settings'." in my xml file . To me, my code is correct, but obviously it shouldn't be..
My xml file:
My xsd file(has no errors):
If i change the xsi:settings in settings, in the xml, i get a "No grammar constraints (DTD or XML Schema) referenced in the document.".
[1.1] Related to it the close tag should thereby be </settings>, as a matter of course.
[1.2] I take the assumption that settings is an element in no namespace. That is the assumption up to now the most reasonable to make. If not, it cannot in the well-known namespace of XMLSchema in any case. That is guaranteed to be an error.
[1.3] There is normally no pressing reason even to specify the location of the schema document, unless for some reason related only to the way you have in mind how the xml document is consumed that ought to do so.
[2.1] There should not be a targetNamespace attribute there as the document to be described by it is in no namespace.
edit note: rectified the xsi namespace propre.
Joined: Jul 31, 2012
Thank you very much for these explanations. It works. However, i tried to change the name of my namespaces and it didn't work. I got an error for each element which told me that "http://www.w3.org/2001/XMLSchema" is the apropriate name.
Joined: Jan 18, 2011
However, i tried to change the name of my namespaces and it didn't work.
This is an exercise that practically rarely help by trial-and-error, you risk even to pick up wrong concepts. There are many elements that must be working together in the schema design to validate certain type of document instances. You've to look at many correct realizations to realize all elements you read and learned on w3c schema suddenly falling into place.
 If you want to make the vocabulary used in your xml document defined in a namespace---your own, you _can't_ borrow some well-known namespace such as http://www.w3.org/2001/XMLSchema, for instance---with its urn being say "urn:xyz" for instance. This is how it would look like. (Namespace prefix is arbitrary but governed by the syntactic requirement all the same. But I use the device of default namespace to make you confuse for a moment, I hope not for long. You have to read tutorials, and at some later time, the recommendation itself after you've got some ideas of the key concepts.)
 And then your_schema.xsd would eventually look like this.