xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> does the xmlns or xmlns:someprefix need to be same as the "targetNamespace" ? if you are not prefixing the xmlns (when refering to targetNamespace) i dont' understand what purpose does it solve ?
does the xmlns or xmlns:someprefix need to be same as the "targetNamespace" ? Not sure, later........ if you are not prefixing the xmlns (when refering to targetNamespace) i dont' understand what purpose does it solve ? If you are not prefixing, the it is considered default namespace. So you do not need to prefix every element. Say your default name space changes and your previous elements are still in the older name space. That is one scenario I can think of. That said, your XML will not validate without a namespace prefix, with some of the parsers. Hence, it is a good idea to use the prefix. Atleast that's what we do in our app. Thanks. - madhav
As far as I have understood, this means essentially that in your schema, when you use an reference to an another element, you don't need to prefix it with a namespace declaration, because it implicitly refers to the element in the targetNamespace. But, when you make now the Schema the default schema, like this:
you have to prefix all the referenced elements with a namespace prefix that is the same as the targetNamespace. So the rule seems to be: make what you want, but always refere to the elements so that they belong to the targetNamespace... Hope this helps, Cyril. Edited: Disabled smiles. - madhav [ August 11, 2003: Message edited by: Madhav Lakkapragada ]
SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
Joined: Jul 02, 2003
Hi, Just another thing about targetNamespace: in case of inclusion of schemas in another schema, the included scheam will take on the the targetNamespace of the schema that is doing the <include>. This is called the Cameleon Effect and the components in the no-namespace schema are called Chameleon components. Cyril.