I am realy frustrated with namespaces. Can anyone tell me a one stop solution to study namespaces. A web-site/page will be the best. For example take a look at this - <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> What is the difference between the "xmlns:xs" , "targetNamespace" & "xmlns" ? I mean why do they need 3 and what is each one for ? PLEASE HELP. Avinash.
Joined: May 30, 2002
Take a look at the description that w3schools has given - The <schema> element may contain some attributes. A schema declaration often looks something like this: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified"> ... ... </xs:schema>
The following fragment: xmlns:xs="http://www.w3.org/2001/XMLSchema"
indicates that the elements and data types used in the schema (schema, element, complexType, sequence, string, boolean, etc.) come from the "http://www.w3.org/2001/XMLSchema" namespace. It also specifies that the elements and data types that come from the "http://www.w3.org/2001/XMLSchema" namespace should be prefixed with xs: !! This fragment: targetNamespace="http://www.w3schools.com"
indicates that the elements defined by this schema (note, to, from, heading, body.) come from the "http://www.w3schools.com" namespace. This fragment: xmlns="http://www.w3schools.com"
indicates that the default namespace is "http://www.w3schools.com". This fragment: elementFormDefault="qualified"
indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified. _________________________________________________ Mark it - xmlns="http://www.w3schools.com" indicates that the default namespace is "http://www.w3schools.com" What does this mean !!! Once you specify a namespace the why do you need default one ? This is nightmare ! PLEASE HELP. Avi
Joined: Mar 29, 2001
Hi, Check out the tutorial at www.xfront.com which has good stuff about schemas -Shoba
Joined: Apr 04, 2001
Namespaces, they say, are simple. However, I find them not. To my mind, a simple one page NS overview is out of the question. NS may be applied to elements, attributes, and data-types. However, just because a name has a colon : in it, doesn't put it in a NS. On the other hand, a name without a : may still be in an NS. Oddly, colon is a valid starting character for names. Elements with the same local name but different NS can co-exist in the same document. However, Attributes with the same local name, but different NS prefixes cannot co-oexist in the same Element. NS definitions in Schemas are complicated by the schema attributes, targetNamespace, elementFormDefault, and attributeFormDefault, includes, imports, and redefines. And NS prefixes don't mean much. I once thought the prefix WAS the NS, and that the URL was meaningless. But I was wrong. So, there is much to learn, to mull over, and so forth, regarding NS. Learn slowly, and retain it all.