一个完整的schema验证xml的例子

xml文件:
<reference xmlns="http://www.w3school.com.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3school.com.cn J.xsd">
	<author authorLoc="1">陈路瑶</author>
	<title>信息文档结构信任模式的提取及逻辑描述</title>
	<type>J</type>
	<publisher>计算机应用研究</publisher>
	<publish_year>2010</publish_year>
	<volumn_mark>27</volumn_mark>
	<page_number>4624-4629</page_number>
</reference>

schema文件(J.xsd):

<?xml version="1.0" encoding="GB2312"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3school.com.cn" targetNamespace="http://www.w3school.com.cn" elementFormDefault="qualified">
	<xs:element name="reference">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="author" type="authorInfo" minOccurs="1" maxOccurs="1"/>
				<xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1"/>
				<xs:element name="type" type="xs:string" minOccurs="1" maxOccurs="1"/>
				<xs:element name="publish" type="xs:string" minOccurs="0" maxOccurs="1"/>
				<xs:element name="publisher" type="xs:string" minOccurs="1" maxOccurs="1"/>
				<xs:element name="publish_year" type="xs:string" minOccurs="1" maxOccurs="1"/>
				<xs:element name="volumn_mark" type="xs:string" minOccurs="1" maxOccurs="1"/>
				<xs:element name="page_number" minOccurs="1" maxOccurs="1">
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:pattern value="(\d{1,4}-)?\d{1,4}"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:complexType name="authorInfo">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="authorLoc" use="required">
					<xs:simpleType>
						<xs:restriction base="xs:integer">
							<xs:enumeration value="1"/>
						</xs:restriction>
					</xs:simpleType>
				</xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
</xs:schema>

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-24 05:27:50

一个完整的schema验证xml的例子的相关文章

一个完整的schema验证xml的样例

xml文件: <reference xmlns="http://www.w3school.com.cn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3school.com.cn J.xsd"> <author authorLoc="1">陈路瑶</author>

dskinlite(uieasy mfc界面库)使用记录1: schema验证xml

市场上的MFC第三方库很多,最终选定dskinlite企业版,成熟度比较高,当然价格也略贵. 在2017年仍然使用MFC是有些另类,但特定场景很适用,也适合不愿转型的老程序员. 目前处于学习阶段,欢迎加扣扣交流(80101277) xml达到一定规模后,验证文档有效性成了当务之急,通常有命令行的xmlint.这里推荐xmlspy(有2013破解版). 例如: <color id="system_bg" value="RGB(255,255)" />  

Schema验证XML文档

1.什么是Schema 2.样板 3.为什么要用Schema 4.Schema文档结构 5.数据类型   6.基本数据类型 7.扩展数据类型 8.数据类型的特性 9.元素 类型 10.element元素 11.group元素

一个HTML用户名密码验证模块的例子

整理出来以前自己积累的代码,需要的时候可以拿来用.天下武功,唯快不破. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head>

XML(五)-Schema验证

Schema 什么是Schema Schema(模式) :其作用与DTD一样,也是用于验证XML文档的有效性,只不过它提供了比DTD更强大的功能和更细粒度的数据类型.另外,Schema可以自定义数据类型. Schema也是一个XML文件,而DTD则不是. Schema与DTD的比较 为何要Schema Schema文档结构: 所有的Schema文档,其根元素必须叫schema.schema可以包含属性,比如: <?xml version="1.0"?> <xs:sch

XML Schema验证

XML Schema验证 一.什么事Schema(XSD) XML Schema是微软定义的一套用来验证XML技术.是一套预先规定的XML元素和属性创建的,这些元素和属性定义了XML文档的结构和内容模式. DTD的局限性: 1.DTD不遵循XML语法. 2.DTD的数据类型有限,与数据库类型不一致. 3.DTD不可以扩展. 4.DTD是不支持命名空间的. Schema的优势: 1.Schema是一种XML语法结构,编写更加方便. 2.Schema可以支持数据类型. 3.Schema是可以扩展的.

XSD(XML Schema Definition)用法实例介绍以及C#使用xsd文件验证XML格式

XSD(XML Schema Definition)用法实例介绍以及C#使用xsd文件验证XML格式 http://blog.csdn.net/gdjlc/article/details/11374787 2013-09-08 12:16 2824人阅读 评论(0) 收藏 举报 分类: XML(5) 版权声明:本文为博主原创文章,未经博主允许不得转载. XML Schema 语言也称作 XML Schema 定义(XML Schema Definition,XSD),作用是定义 XML 文档的合

使用Asp.Net中的XmlValidatingReader来验证XML Schema.

这段时间,我正在学习XML,书上介绍使用Xerces-C或Xerces-J来验证XML文档的Schema或DTD,结果,发现上面的工具不好用. 后来,只有放下书,到书店看看,有没有其他什么书能带来帮助.当检到Professiona ASP.NET XML with C# 这本书时,里面讲到了使用System.Xml 和 System.Xml.Schema命名空间下的XmlTextReader类和XmlValidatingReader类来验证带有Schema或DTD的XML文档.便买下来了. 回寝

一个完整的使用成员函数指针的例子

Screen.h #ifndef SCREEN_H #define SCREEN_H #include <string> class Screen { public: typedef std::string::size_type pos; // Action is a type that can point to a member function of Screen // that returns a reference to a Screen and takes no arguments