aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "namespace and targetnamespace" Watch "namespace and targetnamespace" New topic
Author

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.
Thanks


Jeff Mutonho

SCJP
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
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.

Example:

The targetNamespace is "http://www.Monson-Haefel.com/jwsbook".
Types created:
  • {http://www.Monson-Haefel.com/jwsbook}USAddress
  • {http://www.Monson-Haefel.com/jwsbook}Book
  • {http://www.Monson-Haefel.com/jwsbook}PurchaseOrder


  • Elements created:
  • {http://www.Monson-Haefel.com/jwsbook}purchaseOrder
  • {http://www.Monson-Haefel.com/jwsbook}address


  • Note however that there is also a namespace declaration xmlns:mh="http://www.Monson-Haefel.com/jwsbook". So when you reference anything that exists in the "http://www.Monson-Haefel.com/jwsbook" 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 {http://www.Monson-Haefel.com/jwsbook}USAddress is referenced as mh:USAddress and {http://www.Monson-Haefel.com/jwsbook}Book is referenced as mh:Book.

    Ronald Bourret's XML Namespaces FAQ
    James Clark: XML Namespaces


    "Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
    Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
    jeff mutonho
    Ranch Hand

    Joined: Apr 30, 2003
    Posts: 271
    Thanks.That really helped
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: namespace and targetnamespace
     
    Similar Threads
    With the recession kicking in, is it a good idea to go to USA on H1B consulting jobs?
    Close To 57,000 H1B Petition Approved Year To Date
    Java accessing Hard disk clusters?
    Displaying javascript alerts by reading from ApplicationResources
    WA #1.....word association