如何寫一個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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM