加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml 指定约束文件

发布时间:2020-12-16 08:27:51 所属栏目:百科 来源:网络整理
导读:一. 使用schemaLocation: 辅助xmlns引入“实”的命名空间,指定具体的命名空间所指向的文件,需要具体路径。2部分组成: 定义好的命名空间路径 + 具体schema文件的路径 参考:http://www.jb51.cc/article/p-hfddcuuj-gq.html book.xml ?xml version="1.0" en

一. 使用schemaLocation:

辅助xmlns引入“实”的命名空间,指定具体的命名空间所指向的文件,需要具体路径。2部分组成:定义好的命名空间路径 + 具体schema文件的路径

参考:http://www.52php.cn/article/p-hfddcuuj-gq.html

book.xml

<?xml version="1.0" encoding="UTF-8"?>  
<书架 xmlns="http://www.example.org/NewXMLSchema"  
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
     xsi:schemaLocation = "http://www.example.org/NewXMLSchema ../xsd/A.xsd">
		<书>  
	        <书名>XML基础</书名> 
	        <作者>SAM-SHO</作者>  
	        <售价>28.00元</售价>
	        <出版时间>12</出版时间>
	        <数量>154</数量>
	        <出版年限>123</出版年限>
	    </书>  
</书架>

A.xsd

<?xml version="1.0" encoding="UTF-8"?>  
<schema xmlns="http://www.w3.org/2001/XMLSchema"   
        targetNamespace="http://www.example.org/NewXMLSchema"   
        xmlns:tns="http://www.example.org/NewXMLSchema"   
        elementFormDefault="qualified">  
  
    <element name="书架"> <!--声明<书架>元素-->  
        <complexType><!--声明<书架>元素为复杂类型-->  
            <sequence maxOccurs="unbounded"><!--声明<书架>元素 sequence-有顺序; maxOccurs-无上限-->  
                <element name="书"><!--声明<书>元素-->  
                    <complexType>  
                        <sequence>  
                            <element name="书名" type="string"></element><!--声明<书名>等元素的类型为string-->  
                            <element name="作者" type="string"></element>  
                            <element name="售价" type="string"></element>
                            <element name="出版时间"  type="string"></element>
                            <element name="数量"  type="integer"></element>
                            <element name="出版年限"  type="int"></element>
                        </sequence>  
                    </complexType>  
                </element>  
            </sequence>  
        </complexType>  
    </element>  
      
</schema>

二. 使用 eclipse 引入xsd

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读