Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

targetNamespace,xmlns

 
rahul dighe
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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 ]
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic