WebService筆記-Schema約束

來源:互聯網
上載者:User

標籤:

                    Schema約束

俗話說得好 好記性不如爛筆頭。

看了下WebService視頻,覺得還是得下筆記。

觀看的視頻地址:http://edu.51cto.com/lesson/id-25757.html

複習下xml約束  bool.xsd是book.xml的約束文檔

 1 <schema xmlns="http://www.w3.org/2001/XMLSchema" 2     targetNamespace="http://www.atguigu.com/bookSchema" 3     elementFormDefault="qualified"> 4     <element name="書架"> 5         <complexType> 6             <sequence maxOccurs="unbounded"> 7                 <element name="書"> 8                     <complexType> 9                         <sequence>10                             <element name="書名" type="string" />11                             <element name="作者" type="string" />12                             <element name="售價" type="string" />13                         </sequence>14                     </complexType>15                 </element>16             </sequence>17         </complexType>18     </element>19 </schema>

 

 

element:根項目
complexType:符合類型
sequence:序列        maxOccurs的值代表了無上限的意思

 <書架>    <書>      <書名></書名>      <作者></作者>      <售價></售價>    </書>    <書>      <書名></書名>      <作者></作者>      <售價></售價>    </書> </書架> 

schema規範中:
1. 所有標籤和屬性都需要有schema檔案來定義
2. 所有的schema檔案都需要有一個id, 但在這裡它叫namespace,
3. namespace的值由什麼來指定?
  由targetNamespace屬性來指定, 它的值是一個url(很有可能不存在)
4. 如何引入一個Schema約束?
  屬性? : 用xmlns屬性
  屬性值: 對應的schema檔案的id(namespace值)

5. 如果引入的schema不是w3c組織定義, 必須指定schema檔案的位置
6. schema檔案的位置由什麼屬性來指定?
  屬性? : schemaLocation
  屬性值: namespace path=====》id+空格+路徑
7. 如果引入了N個約束, 需要給n-1個取別名

 1 <?xml version="1.0" encoding="UTF-8"?> 2 <書架 xmlns="http://www.atguigu.com/bookSchema" 3     xmlns:dd="http://www.w3.org/2001/XMLSchema-instance" 4     dd:schemaLocation="http://www.atguigu.com/bookSchema book.xsd"> 5     <書> 6         <書名>JavaScript開發</書名> 7         <作者>老佟</作者> 8         <售價>28.00元</售價> 9     </書>10 </書架>
schemaLocation  是由w3c定義 所以必須引入w3c的規範xmlns:dd="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dd 起別名  不然會起衝突 報錯

  

 

大家可以聯絡到spring設定檔的

xmlns:context

xmlns:aop

 

看了視頻的第一節複習內容到此就結束了   新手第一次寫 勿噴  請大家指出錯誤  萬謝~!

 

   

 

 

WebService筆記-Schema約束

聯繫我們

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