如何写一个schema文件

<!-- xmlns:默认的命名空间,一个 schema中只允许有一个xmlns,因为应用这个命名空间的资源不用添加前缀,其他的命名空间需要添加前缀 -->
<!-- targetNamespace:是别的schema或者xml文件引用本schema文件的路径, -->
<!-- targetNamespace和xmlns:tns是一致的,什么意思呢,就是说在本页面如果要引用本页面的一些资源,就要加入tns这个前缀才能引用,不然就是引用默认命名空间xmlns的资源 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/persion"
    xmlns:tns="http://www.example.org/persion" elementFormDefault="qualified">

    <element name="persion">
        <complexType>
            <sequence>
                <element name="id" type="int"></element>
                <element name="username" type="string"></element>
                <element name="time" type="date"></element>
            </sequence>
        </complexType>
    </element>
</schema>
<?xml version="1.0" encoding="UTF-8"?>
<persion xmlns="http://www.example.org/persion" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.example.org/persion">

    <id>1</id>
    <username>sfz</username>
    <time>1992-01-12</time>
    
</persion>
原文地址:https://www.cnblogs.com/songfahzun/p/5888440.html