File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes namespace and targetnamespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "namespace and targetnamespace" Watch "namespace and targetnamespace" New topic

namespace and targetnamespace

jeff mutonho
Ranch Hand

Joined: Apr 30, 2003
Posts: 271
Can someone explain the difference between these 2? Or perhaps refer me to some document/book that explains this clearly.

Jeff Mutonho

Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
targetNamespace is used in XML Schemas and WSDL to identify and select the namespace into which new elements that your are defining are created in. Once you have defined a new element you still need a namespace declaration to be able to reference the new element or type.


The targetNamespace is "".
Types created:
  • {}USAddress
  • {}Book
  • {}PurchaseOrder

  • Elements created:
  • {}purchaseOrder
  • {}address

  • Note however that there is also a namespace declaration xmlns:mh="". So when you reference anything that exists in the "" namespace you simply use the prefix "mh" within the scope of that element (in this case schema). This is used in the PurchaseOrder type definition where {}USAddress is referenced as mh:USAddress and {}Book is referenced as mh:Book.

    Ronald Bourret's XML Namespaces FAQ
    James Clark: XML Namespaces
    jeff mutonho
    Ranch Hand

    Joined: Apr 30, 2003
    Posts: 271
    Thanks.That really helped
    I agree. Here's the link:
    subject: namespace and targetnamespace
    It's not a secret anymore!