Missunderstanding schema namespaces
-
I really don`t understand schemas namespaces and reading books also not clear my mind. My questions are: - what's the difference between xmlns and targetNamespace - if I change the targetNamespace of the schema pointing to one urn of my own all schema, which before was working, start having errors, I thought that targetNamespace point to one opaque urn and taht you can change it?. - also some books mention that if you are to validate a Xml file with a schema the elements of both files must belong to the sames namespace, but the only way I get validation working is if I don´t set any namespace in the Xml file. Please could somebody explain me shortly the rules for this schema namespace or some link where it's clearly explained, no so ambiguous explanations as I found until now. Best Regards
-
I really don`t understand schemas namespaces and reading books also not clear my mind. My questions are: - what's the difference between xmlns and targetNamespace - if I change the targetNamespace of the schema pointing to one urn of my own all schema, which before was working, start having errors, I thought that targetNamespace point to one opaque urn and taht you can change it?. - also some books mention that if you are to validate a Xml file with a schema the elements of both files must belong to the sames namespace, but the only way I get validation working is if I don´t set any namespace in the Xml file. Please could somebody explain me shortly the rules for this schema namespace or some link where it's clearly explained, no so ambiguous explanations as I found until now. Best Regards
1. xmlns xmlns is described here: http://www.w3schools.com/XML/xml_namespaces.asp[^] We can read there: When using prefixes in XML, a so-called namespace for the prefix must be defined. And the example: <h:table xmlns:h="http://www.w3.org/TR/html4/"> The xmlns defines what h prefix means. It must be in the XML document. 2. targetNamespace You can read about it here: http://www.w3schools.com/schema/el_schema.asp[^] It's used in XML schemas. We can read there: targetNamespace - Optional. A URI reference of the namespace of this schema That's the defference between them. PS. In the XML schamas there's a line: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> By this xmlns, you define what xs prefix means, so this means that you shouldn't change it.