• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TargetNameSpace

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can any one tell me what is TargetNameSpace and what is the use of that.

Thanks in advance.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
targetNamespace is used to define a namespace for the document that you are defining it now.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See namespace and targetnamespace
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,
I still have doubt :
1.Is it necessary to have targetnamesapce and namepsace to be same(URI).
2.In your example Targetnamespace and namespace are both same so why did again we use namespace for purchaseOrder and Address.Is it it pinting to different location.
2.In the example we have used prefix only for namespace not for Target namespace. why so??

As far as understood TargetNamespace is like default namespace.I am in the right way?
Please help me in understaing it clearly.
Thanks in advance.
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Divya Gehlot:
1.Is it necessary to have targetnamesapce and namepsace to be same



Not if you are not referencing anything that you are defining. As soon as your are trying to reference anything in that namespace it has to be the default namespace or a namespace with an assigned prefix.

xmlns="http://www.w3.org/2001/XMLSchema"
this means that {http://www.w3.org/2001/XMLSchema} is the default namespace - therefore any of the XML Schema elements don't need a prefix.

xmlns:mh="http://www.Monson-Haefel.com/jwsbook"
assigns the "mh" prefix to the {http://www.Monson-Haefel.com/jwsbook} namespace. So whenever we refer an element or type that exists in that namespace we have to prefix it with "mh"

targetNamespace="http://www.Monson-Haefel.com/jwsbook"
this simply states that any elements and types that are defined by the Schema (or WSDL) are in created the {http://www.Monson-Haefel.com/jwsbook} namespace. It doesn't create a means for you to refer to anything in the {http://www.Monson-Haefel.com/jwsbook} namespace. This is why you have to use the "mh" prefix assigned by the namespace declaration when you are using mh:USAddress, mh:Book, mh:PurchaseOrder.

3.In the example we have used prefix only for namespace not for Target namespace. why so??


"xmlns" is a namespace declaration which can assign a prefix.
"targetNamespace" isn't a namespace declaration - it simply specifies the target namespace into which the new elements and types are defined into.

As far as understood TargetNamespace is like default namespace. I am in the right way?


No, that is incorrect.


However the default namespace can be the targetNamespace:

Now the default namespace is the target namespace. However now all of the XML Schema elements have to be prefixed with "xsd" - "xsd:schema", "xsd:complexType", "xsd:sequence" ...
[ February 29, 2008: Message edited by: Peer Reynders ]
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,
Thanks alot for your explanation
Still I have some doubt
"targetNamespace" isn't a namespace declaration - it simply specifies the target namespace into which the new elements and types are defined into
What do you mean by "simply specifies the target namespace into which the new elements and types are defined into"
[ February 29, 2008: Message edited by: Divya Gehlot ]
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Divya Gehlot:
What do you mean by "simply specifies the target namespace into which the new elements and types are defined into"



XML Schema and WSDL files define new XML types and XML elements. Those types and elements must belong to a namespace. targetNamespace specifies which namespace that is.

Think of "targetNamespace" as what "package" is to Java. However you have to assign a targetNamespace - you cannot leave it blank.
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peer,
Thanks a lot . Now its clear for me.
Your explaination really helped in understanding the namespaces.
reply
    Bookmark Topic Watch Topic
  • New Topic