XML Schema使用基础

XML(Extensible Markup Language)可扩展标记语言
1.xml声明

<?xml version="1.0" encoding="UTF-8"?>

文件符合xml1.0规范,文字编码为UTF-8

2.命名空间
当我们使用不同文档的相同标签时会发生冲突,使用命名空间来避免冲突。

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

</beans>

xmlns全称xmlnamespace。

上述指定了4个命名空间,包括一个默认命名空间xmlns=”http://www.springframework.org/schema/beans”,还有xmlns:mvc,xmlns:context,xmlns:xsi。

xmlns:xsi命名空间拥有一个xsi:schemaLocation属性,该属性可以指定命名空间的xsd文件,如上述xsi:schemaLocation属性的前两行将命名空间xmlns=”http://www.springframework.org/schema/beans”的xsd地址指定为http://www.springframework.org/schema/beans/spring-beans.xsd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值