Thread: Namespaces

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Poland
    Posts
    4
    Rep Power
    0

    Namespaces


    Hi,
    I've got a code example:

    Code:
    <a xmlns:b="urn:b">
        <c xmlns="urn:x">
    	<d:e xmlns="urn:y"
                 xmlns:d="urn:d"
                 b:f="g">
                <i xmlns:b="urn:b2">
                    <j b:k="l"/>
                </i>
            </d:e>
            <m n="o"/>
        </c>
        <p/>
    </a>
    Can anyone explain/tell me to which namespace each name belongs and why?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    Pick any node. Is there a namespace prefix on it? If so then find the namespace URI for that prefix. If not then find the closest xmlns without a suffix and use that URI, and if there isn't one then it's in the default namespace.

    Same idea for attributes: if there's a prefix then find the closest xmlnsrefix, otherwise look for the nearest xmlns.

    Given that, what do you think the answers are?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Poland
    Posts
    4
    Rep Power
    0
    Hmm..

    a - doesn't belong to any namespace
    c - belongs to urn:x
    e - belongs to urn:d
    f - belongs to urn:b
    i - belongs to urn:y
    j - belongs to urn:y
    k - belongs to urn:b2
    m - belongs to urn:x
    n - doesn't belong to any namespace
    p - doesn't belong to any namespace

    is this correct?

IMN logo majestic logo threadwatch logo seochat tools logo