4

I often see code like the one below in XML schema files. As far as I understood xmlns is to define a new namespace. But are the long URLs that follow a xmlns really necessary? I mean does the program, parser, whatever really make a call to, e.g. "http://www.springframework.org/schema/beans"? Or could the line simply like this here:

<beans xmlns="beansNamespace">

Here's one of the

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
"
>
1

1 Answer 1

6

No, the parser does not go to http://whatever, when it sees
<element xmlns='http://whatever...'>

The IETF recommends that XML namespaces be URIs, but that URI need not be an HTTP URI, and in fact it need not have any "network protocol" attached to it. They are used for identification only.

In some cases people design namespace URIs as HTTP URIs, and they insert human-readable documentation for the namespace at that URI. so if a human were to visit the place, they'd learn about the schema with that namespace. But that convention is not widely adopted.

See also, What does "xmlns" in XML mean?
and, What causes a difference between a web service URL and a namespace?

Sign up to request clarification or add additional context in comments.

1 Comment

It's also worth reading James Clark's namespaces tutorial at jclark.com/xml/xmlns.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.