Java: 玩轉schema+xmlbeans (1)

來源:互聯網
上載者:User

最近在公司問了一下,知道schema的人很少,能夠運用的更是鳳毛麟角.

schema是用來定義xml的,就象定義資料庫中庫中要定義表結構,沒有schma的xml是一盤散沙.

在很多產品中,都能看到schema的身影,比如.net中的dataset,Office中的infopath,WebService中的wsdl...

schema的一些特點:
    定義簡單和複雜的資料結構
    用NameSpace來區別,相互引用
    語言無關
    可以加入描述等附加資訊...

先看看schema的簡易功能:

簡單類型,基於String, 長度介於2~5位

    <xs:simpleType name="chineseName">
        <xs:restriction base="xs:string">
            <xs:maxLength value="5"/>
            <xs:minLength value="2"/>
        </xs:restriction>
    </xs:simpleType>

簡單類型,基於String,用Regex限定格式:

    <xs:simpleType name="arenumber">
        <xs:restriction base="xs:string">
            <xs:pattern value="0[1-9][0-9]{1,2}"/>
        </xs:restriction>
    </xs:simpleType>

簡單類型,基於String,枚舉:

    <xs:simpleType name="gender">
        <xs:restriction base="xs:string">
            <xs:enumeration value="男"/>
            <xs:enumeration value="女"/>
        </xs:restriction>
    </xs:simpleType>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.