I see that we have multiple url's as value of this attribute like in spring:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
Why is it needed and what is it used for? Does Spring goes to the url and validate? what is the difference between xmlns and xsi:schemaLocation?
The Java XML parser that spring uses will read the schemaLocation
values and try to load them from the internet, in order to validate the XML file. Spring, in turn, intercepts those load requests and serves up versions from inside its own JAR files.
If you omit the schemaLocation
, then the XML parser won't know where to get the schema in order to validate the config.