webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Difference between xmlns and targetNamespace attributes

  • 1.  Difference between xmlns and targetNamespace attributes

    Posted Thu May 24, 2007 08:09 AM

    Hi,

    [html]<?xml version="1.0"?>
    <xsd:schema xmlns:xsd=“XML Schema
    targetNamespace=“http://www.abc.com
    xmlns=“http://www.abc.com
    elementFormDefault=“qualified”>[/html]

    Here, I understand that targetNamespace indicates that the elements declared in the schema will go in the “http://www.abc.com” namespace.

    What is the significance of xmlns attributes? How xmlns attribute is different from targetNamespace attribute? :confused:


    #soa
    #API-Management
    #webMethods


  • 2.  RE: Difference between xmlns and targetNamespace attributes

    Posted Thu May 24, 2007 01:27 PM

    The target namespace is used for the internal referencing in the xml document to make sure it is valid as declared from the schema. The xmlns attribute actually declares the namespace of a particular element or group of elements.

    In the example you have given: [html]xmlns=“http://www.abc.com”[/html]

    [URL="http://www.abc.com/"]http://www.abc.com[/URL]

    is the default namespace. You can tell it is the default by the lack of a prefix. This means any elements that are a child of this root element and do not have an explicit namespace declared will belong to this namespace. Any element belonging to the [html]xmlns:xsd=http://www.w3.org/2001/XMLSchema[/html] would have a prefix of XSD.

    If both namespaces had prefixes then there is no default namespace and the elements would have either a prefix to designate which namespace they belong to or no prefix to designate that they have no namespace.

    Here is a pretty good article from Oracle on the subject - [URL=“http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html”]http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html[/URL]

    hope this helps


    #webMethods
    #soa
    #API-Management


  • 3.  RE: Difference between xmlns and targetNamespace attributes

    Posted Thu May 24, 2007 01:33 PM

    Thanks for the help Mark. The article is very helful.


    #API-Management
    #webMethods
    #soa