zoukankan      html  css  js  c++  java
  • schema(二)为xml文件添加多个schema约束

    当一个xml 文件有多个schema约束是可以一个为默认的,其它的都加前缀。

    department.xsd

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- 数据文件,引用多个Schema -->
    <company xmlns="http://www.example.org/company" xmlns:dept="http://www.example.org/department"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.example.org/company company.xsd 
        http://www.example.org/department department.xsd">
        <employee age="30">
            <!-- 部门名称 -->
            <dept:name>人力资源部</dept:name>
            <!-- 员工名称 -->
            <name>王小小</name>
        </employee>
    </company>

    company.xsd

    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/department"
        xmlns:tns="http://www.example.org/department" elementFormDefault="qualified">
        <element name="name" type="string">
        </element>
    </schema>

    company.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- 数据文件,引用多个Schema -->
    <company xmlns="http://www.example.org/company" xmlns:dept="http://www.example.org/department"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.example.org/company company.xsd 
        http://www.example.org/department department.xsd">
        <employee age="30">
            <!-- 部门名称 -->
            <dept:name>人力资源部</dept:name>
            <!-- 员工名称 -->
            <name>王小小</name>
        </employee>
    </company>

    Result:

  • 相关阅读:
    MongoDB 3.0 添加用户
    MongoDB基本命令用
    http://www.bootcss.com/
    UML之用例图
    .net 下分布式缓存(Memcached)实现
    Android系列 -- 2、视图组件View
    Android系列 -- 1、 初识android
    TP50、TP90、TP99、TP999详解
    Linux下SSD缓存加速之bcache使用
    数据中心常见电源线详细介绍
  • 原文地址:https://www.cnblogs.com/jianfengyun/p/3823844.html
Copyright © 2011-2022 走看看