|NO.Z.00117|——————————|BigDataEnd|——|Java&MySQL.XML.V08|——|MySQL.v08|引入schema约束|

一、XML引入Schema约束
### --- xml中引入schema约束的步骤:

~~~     # 查看schema文档,找到根元素,在xml中写出来
<?xml version="1.0" encoding="UTF-8" ?>
    
<students>
</students>
~~~     # 根元素来自哪个命名空间。使用xmlns指令来声明

<?xml version="1.0" encoding="UTF-8" ?>
<students
    xmlns="http://www.yanqi.com/xml"
>
    
</students>
~~~     # 引入 w3c的标准命名空间, 复制即可

<?xml version="1.0" encoding="UTF-8" ?>
<students
    xmlns="http://www.yanqi.com/xml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

>
</students>
~~~     # 引入的命名空间跟哪个xsd文件对应?
~~~     # 使用schemaLocation来指定:两个取值:第一个为命名空间 第二个为xsd文件的路径

<?xml version="1.0" encoding="UTF-8" ?>
<students
    xmlns="http://www.yanqi.com/xml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.yanqi.com/xml student.xsd"
>
</students>
~~~     # 命名空间

~~~     指的是一个环境,所用的标签来自于哪个环境定义的。
~~~     # student.xml

<?xml version="1.0" encoding="UTF-8" ?>
<students
    xmlns="http://www.yanqi.com/xml"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.yanqi.com/xml student.xsd"
>
    <student number="hehe_1234">
        <name>张百万</name>
        <age>25</age>
        <sex>female</sex>
    </student>

    <student number="hehe_0000">
        <name>小斌</name>
        <age>20</age>
        <sex>male</sex>
    </student>
</students>
二、xml语句
<?xml version="1.0" encoding="UTF-8" ?>
<students
        xmlns="http://www.yanqi.com/xml"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.yanqi.com/xml student.xsd"
>
    <student number="hehe_1234">
        <name>张三</name>
        <age>200</age>
        <sex>male</sex>
    </student>

    <student number="hehe_4567">
        <name>张三</name>
        <age>200</age>
        <sex>male</sex>
    </student>

</students>

 
 
 
 
 
 
 
 
 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

posted on   yanqi_vip  阅读(26)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示