XML Namespaces Explained: xmlns and xsi:schemaLocation
Publication Date:
Updated:
INFORMATION > XML Namespaces Explained: xmlns and xsi:schemaLocation
Bottom line: xmlns binds a prefix or default namespace to a URI so element names remain unambiguous. xsi:schemaLocation is only a hint that pairs namespace URIs with schema locations; validation behavior still depends on the XML processor.
What you'll learn
- How default and prefixed namespaces change an element's expanded name.
- Why a namespace URI is an identifier and does not have to return a web page.
- How
xsi:schemaLocationdiffers fromxsi:noNamespaceSchemaLocation.
Who this is for: Developers reading Maven, Spring, SOAP, or other XML configuration files.
2026 context: The W3C namespace and XML Schema rules remain the authority. Treat remote schema locations as untrusted input and avoid depending on network retrieval during production parsing.
Overview
This article explains what "xmlns" and "xsi:schemaLocation" mean in XML files.
Table of Contents
1. What is an XML file?
XML stands for Extensible Markup Language and is specified by the World Wide Web Consortium (W3C). The W3C XML specification defines the document syntax; the namespace and XML Schema specifications define the concepts discussed below.
1-1. What are "xmlns" and "xsi:schemaLocation"?
The following Spring configuration demonstrates a default namespace, several prefixed namespaces, and the schema-location hint.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
The namespace declarations identify the vocabulary used by each element and attribute; xsi:schemaLocation pairs namespace names with schema-location hints. A processor can use the corresponding schema to validate rules such as which attributes and child elements are allowed. Spring also uses namespace-aware parsing to select the handler for each configuration element.
1-2. What is xmlns?
xmlns declares an XML namespace. In xmlns="http://www.springframework.org/schema/beans", the URI identifies the default namespace for unprefixed element names in that scope.
The namespace name looks like a URL, but it is an identifier and does not have to be retrieved over the network. Schema resolution is a separate step. Frameworks such as Spring can map known schema locations to resources packaged in their JAR files.
1-3. What is "xmlns:xsi"?
xmlns:xsi binds the prefix xsi to the XML Schema Instance namespace. The prefix makes names such as xsi:schemaLocation distinct from names in the default namespace. In general, xmlns="…" declares a default namespace, while xmlns:prefix="…" declares a namespace used as prefix:element or prefix:attribute.
2. Conclusion
xmlns declarations identify XML vocabularies. xsi:schemaLocation supplies optional namespace-to-schema hints; it does not itself define the elements, force validation, or guarantee that a remote schema will be fetched.
Official references
■INFORMATION
■PROFILE
■CONTACT