Schema 中的 key 元素

來源:互聯網
上載者:User

Schema中的key元素描述的是各個元素之間的關係,在VS.net中,顯示出來的概念是“關係”。key必須和keyref聯合使用,其中的關係就是 keyref 中的結果集合必須被包含在 key 的結果集中。用VS.net的話說就是key對應的就是“父元素”而keyref對應的就是子項目了---一個包含一個嘛!

另外還要說一句的是,其實key和keyref的定義可以在element元素中的,不過VS.net好像都定義在根項目下面,定義在其他位置設計器找不到哦。

一下就是例子,為了避免幹擾,我把無關元素都刪除了:

<xs:element name="Dictionary">
    <xs:element name="Types">
        <xs:element name="Declare" >   
            <xs:element name="Name" type="xs:ID" />
            <xs:element name="Type" type="xs:string" />
        </xs:element>
    </xs:element>
</xs:element>   
</xs:element>
    <xs:element name="Element" >
        <xs:element name="Name" type="xs:string" />
        <xs:element name="Type" type="xs:string" />
    </xs:element>
</xs:element>

<xs:key name="DeclareTypes">
    <xs:selector xpath=".//NS:Declare" />
    <xs:field xpath="NS:Name" />
</xs:key>
<xs:keyref name="DeclareElement" refer="DeclareTypes">
    <xs:selector xpath=".//NS:Element" />
    <xs:field xpath="NS:Type" />
</xs:keyref>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.