個人備忘–schema

來源:互聯網
上載者:User

xs:complexType使用方法比較:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://mynamespace/schema">
<xs:element name="書本">
<xs:complexType>
        <xs:attribute name="名稱" type="xs:string"/>
        <xs:attribute name="作者" type="xs:string"/>
</xs:complexType>
</xs:element>

</xs:schema>

<?xml version="1.0" encoding="UTF-8"?>
<書本 xmlns="http://mynamespace/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mynamespace/schema file:///C:/Documents%20and%20Settings/Administrator/%e6%a1%8c%e9%9d%a2/Untitled1.xsd" 名稱="書籍" 作者="hehe"/>

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="element" type="myElementType"/>
<xs:complexType name="myElementType">
    <xs:attributeGroup ref="myAttributeGroup"/>
</xs:complexType>
<xs:attributeGroup name="myAttributeGroup">
    <xs:attribute name="someattribute1" type="xs:integer" use="required"/>
    <xs:attribute name="someattribute2" type="xs:string"/>
</xs:attributeGroup>
</xs:schema>

<?xml version="1.0" encoding="UTF-8"?>
<element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/Documents%20and%20Settings/Administrator/%e6%a1%8c%e9%9d%a2/Untitled1.xsd" someattribute1="4"/>

simpleContent元素:

應用於complexType,對它的內容進行約束和擴充。l作用:定義一個簡單類型,它決定了元素和屬性值的約束和相關資訊l屬性: namel內容:應用已經存在的簡單類型,三種方式:lrestriction→限定一個範圍l list→從列表中選擇l union→包含一個值的結合 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:attribute name="allframesize">   <xs:simpleType>     <xs:union>       <xs:simpleType>         <xs:restriction base="roadbikesize"/>       </xs:simpleType>       <xs:simpleType>         <xs:restriction base="mountainbikesize"/>       </xs:simpleType>     </xs:union>   </xs:simpleType> </xs:attribute>

complexType與simpleType區別(重要)l simpleType類型的元素中不能包含元素或者屬性。l當需要聲明一個元素的子項目和/或屬性時,用 complexType;l當需要基於內建的基礎資料型別 (Elementary Data Type)定義一個新的資料類型時,用 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.