Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML validation problem

 
Harald Fiedler
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.".

Thanks in advance for your help.

Just a Game
 
g tsuji
Ranch Hand
Posts: 656
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[1]
<xsi:settings xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://www.w3.org/2001/XMLSchema/Application.xsd">

should read

[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] Here in your "your_schema.xsd", say:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2001/XMLSchema" >

should read

[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.
 
Harald Fiedler
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

[3] 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.)

[4] And then your_schema.xsd would eventually look like this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic