xsi:schemaLocation 有什么用? [英] what is the use of xsi:schemaLocation?

查看:45
本文介绍了xsi:schemaLocation 有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到我们有多个 url 作为这个属性的值,就像在 spring 中一样:

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">

为什么需要它以及它的用途是什么?Spring 是否会访问 url 并进行验证?xmlns 和 xsi:schemaLocation 有什么区别?

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?

推荐答案

spring 使用的 Java XML 解析器将读取 schemaLocation 值并尝试从 Internet 加载它们,以验证XML 文件.反过来,Spring 会拦截这些加载请求,并从其自己的 JAR 文件中提供版本.

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.

如果您省略 schemaLocation,那么 XML 解析器将不知道从哪里获取架构以验证配置.

If you omit the schemaLocation, then the XML parser won't know where to get the schema in order to validate the config.

这篇关于xsi:schemaLocation 有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆