Tạo file XSD schema từ file XML

Thảo luận trong 'Khoa Khoa Học Máy Tính' bắt đầu bởi interpol, 10 Tháng mười hai 2012.

  1. Offline

    interpol

    • Friends

    • Change
    Số bài viết:
    1.414
    Đã được thích:
    1.462
    Điểm thành tích:
    1.550
    Website: http://www.freeformatter.com/xsd-generator.html

    DEMO:
    XML
    Mã:
    <?xml version="1.0"?>
    <DSPHIEUMUON xsi:noNamespaceSchemaLocation="PHIEUMUON.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <PHIEUMUON MaSo="0001" NhanVien="Nguyen Thi Thuong">
            <MASV>LT020003</MASV>
            <HOTEN>Le Kim Chung</HOTEN>
            <LOP>LT02A</LOP>
            <NGAYMUON>2010-09-15</NGAYMUON>
            <NGAYTRA>2010-09-18</NGAYTRA>
            <TAILIEU>
                <SACH>3</SACH>
                <BAO>0</BAO>
                <TAPCHI>1</TAPCHI>
            </TAILIEU>
        </PHIEUMUON>
        <PHIEUMUON MaSo="0002" NhanVien="Nguyen Thi Thuong">
            <MASV>LT020004</MASV>
            <HOTEN>Nguyen Minh Chau</HOTEN>
            <LOP>LT02B</LOP>
            <NGAYMUON>2010-09-15</NGAYMUON>
            <NGAYTRA>2010-10-10</NGAYTRA>
            <TAILIEU>
                <SACH>1</SACH>
                <BAO>2</BAO>
                <TAPCHI>0</TAPCHI>
            </TAILIEU>
        </PHIEUMUON>
    </DSPHIEUMUON>
    
    XSD
    Mã:
    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="DSPHIEUMUON">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="PHIEUMUON" maxOccurs="unbounded" minOccurs="0">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="MASV">
                    <xs:complexType>
                      <xs:simpleContent>
                        <xs:extension base="xs:string">
                          <xs:attribute type="xs:string" name="GT" use="optional"/>
                        </xs:extension>
                      </xs:simpleContent>
                    </xs:complexType>
                  </xs:element>
                  <xs:element type="xs:string" name="HOTEN"/>
                  <xs:element type="xs:string" name="LOP"/>
                  <xs:element type="xs:date" name="NGAYMUON"/>
                  <xs:element type="xs:date" name="NGAYTRA"/>
                  <xs:element name="TAILIEU">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element type="xs:byte" name="SACH"/>
                        <xs:element type="xs:byte" name="BAO"/>
                        <xs:element type="xs:byte" name="TAPCHI"/>
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute type="xs:byte" name="MaSo" use="optional"/>
                <xs:attribute type="xs:string" name="NhanVien" use="optional"/>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    hongoctrien, duyen.only.itsunset_glow thích bài này.

Chia sẻ trang này

Advertising: Linux system admin | nukeviet | nukeviet 4 | Upload ảnh miễn phí