wood burning stoves 2.0*
The moose likes Product and Other Certifications and the fly likes targetNamespace,xmlns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "targetNamespace,xmlns" Watch "targetNamespace,xmlns" New topic
Author

targetNamespace,xmlns

rahul dighe
Ranch Hand

Joined: Apr 17, 2001
Posts: 44
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 ?


<BR>Rahul Dighe
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
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


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247


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
cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: targetNamespace,xmlns
 
Similar Threads
How to use elementFormDefault and attributeFormDefault?
why targetNamespace?
Patterns in XML Schema - how to do it?
Patterns in XML Schema - how to do it?
targetNamespace , xmlns