This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes TargetNameSpace? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "TargetNameSpace?" Watch "TargetNameSpace?" New topic
Author

TargetNameSpace?

Tiger Scott
Ranch Hand

Joined: Mar 01, 2001
Posts: 223
I am going thru the XML Schema specs- I had some basic doubts about TargetNameSpace:
1. TargetNameSpace(TNS) is supposed to provide uniqueness- isn't namespace already providing it. What additional benefits does TNS offer.
2. Does one Schema have only one TargetNameSpace or it can have more? Also if a Schema has more than one NameSpace TargetNameSpace applies to which NameSpace.
TIA
Sanjay
David Peterson
author
Ranch Hand

Joined: Oct 14, 2001
Posts: 154
1. TargetNameSpace(TNS) is supposed to provide uniqueness- isn't namespace already providing it. What additional benefits does TNS offer?

The question makes it sound like "targetNamespace" is a rival namespacing mechanism. This isn't what it is at all.
"targetNamespace" is used in a schema to specify the namespace that the schema is intended to define.
For example the XHTML schema specifies a targetNamespace of "http://www.w3.org/1999/xhtml". The schema defines the structure and content of an XHTML document.
If you create an XHTML document you specify the namespace "http://www.w3.org/1999/xhtml" to indicate that its an XHTML document.
Upon receiving XML that uses the namespace "http://www.w3.org/1999/xhtml", a validating parser could look for the schema with this URI as its targetNamespace and then use the schema to validate the XML it's receiving.
2. Does one Schema have only one TargetNameSpace or it can have more? Also if a Schema has more than one NameSpace TargetNameSpace applies to which NameSpace.

A schema only has one targetNamespace.
David
Tiger Scott
Ranch Hand

Joined: Mar 01, 2001
Posts: 223
David,
Thanks.
Please bear with me- it is still confusing for me.

A schema only has one targetNamespace.
"targetNamespace" is used in a schema to specify the namespace that the schema is intended to define.

So is it that "targetNamespace" is used only in Schema documents. I see some example XML documents with "targetNamespace" ?


For example the XHTML schema specifies a targetNamespace of "http://www.w3.org/1999/xhtml". The schema defines the structure and content of an XHTML document.
If you create an XHTML document you specify the namespace "http://www.w3.org/1999/xhtml" to indicate that its an XHTML document.
Upon receiving XML that uses the namespace "http://www.w3.org/1999/xhtml", a validating parser could look for the schema with this URI as its targetNamespace and then use the schema to validate the XML it's receiving.

So my XML document would link to the "targetNamespace" with the namespace declaration in my XML document. And the linking is based on the URI being the same? Do the URI of "targetNamespace" and namsespace have to be the same?
I think my confusion emanates from my lack of understanding of namespace itself.
TIA
Sanjay


[This message has been edited by Sanjay Bahal (edited November 27, 2001).]
David Peterson
author
Ranch Hand

Joined: Oct 14, 2001
Posts: 154

I think my confusion emanates from my lack of understanding of namespace itself.


Take a look at this
Microsoft XML Tutorial
It might help clarify things with regard to namespaces.


So is it that "targetNamespace" is used only in Schema documents. I see some example XML documents with "targetNamespace" ?

"targetNamespace" is generally used in schemas, and schema-like things, e.g. Web Services Description Language (WSDL).
David
Tiger Scott
Ranch Hand

Joined: Mar 01, 2001
Posts: 223
David,
Thanks.
So if I finally undersatnd it right- NameSpace has nothing to do with DTD or validation- it is just to make a name unique?
DTDs if reqd would be included in the XML document by the DOCTYPE declaration?
TIA
Sanjay
 
GeeCON Prague 2014
 
subject: TargetNameSpace?