zoukankan      html  css  js  c++  java
  • Schema 简单示例, Schema validate xml doc

    工具: 普遍认为 XML spy比较好用,但是商业版.
    EditiX : Free Edition for non commercial useage,免费版供非商业使用
    下载网址:    http://free.editix.com/   但有时被墙.
    本人最新下载的版本:
    Version:2010 [Build 020110]
    Company: http://www.japisoft.com
    本人使用过的特性: schema validate xml, pretty format for xml document.
    schema:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://192.168.10.254:9999/schemaExample/1.0.0" elementFormDefault="qualified" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://192.168.10.254:9999/schemaExample/1.0.0">
    	<xs:element name="note">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="to" type="xs:string"/>
    				<xs:element name="from" type="xs:string"/>
    				<xs:element name="heading" type="xs:string"/>
    				<xs:element name="body" type="xs:string"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>
    

    targetNamespace是任意的.

    <?xml version="1.0" encoding="UTF-8"?>
    <note xsi:schemaLocation="http://192.168.10.254:9999/schemaExample/1.0.0 http://192.168.10.254:9999/note.xsd"
     xmlns="http://192.168.10.254:9999/schemaExample/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    	<from>Jani</from>
    	<to>中国</to>
    	<heading>Reminder</heading>
    	<body>Don't forget me this weekend!</body>
    </note>
    

    xsi:schemaLocation 第一个参数是 xml的命名空间,第二个参数是,schema存放的位置.此时为: http://192.168.10.254:9999/note.xsd
    若是本地文件,则直接写路径就OK了. note.xsd
    编辑后即可检验该xml是否符合schema定义.
  • 相关阅读:
    Hbase 命令小结
    shell while内获取外部变量内容
    Idea的live template参数中的预定义功能
    Adobe Illustrator里使用fontawesome矢量图标
    五笔结构与识别码
    致第一次安装RIME的你
    sublime Text Pastry使用
    PHOTOSHOP CC 2015插件安装方法
    搭建自己的OpenWrt开发环境
    【OpenWRT】 Chaos Calmer 15.05 编译
  • 原文地址:https://www.cnblogs.com/wucg/p/2041988.html
Copyright © 2011-2022 走看看